mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Make clippy behave slightly more reasonably
This commit is contained in:
parent
418ef10af2
commit
1207a7cc06
@ -1,3 +1,10 @@
|
|||||||
|
// This is used when either vtab or modern-sqlite is on. Different methods are
|
||||||
|
// used in each feature. Avoid having to track this for each function. We will
|
||||||
|
// still warn for anything that's not used by either, though.
|
||||||
|
#![cfg_attr(
|
||||||
|
not(all(feature = "vtab", feature = "modern-sqlite")),
|
||||||
|
allow(dead_code)
|
||||||
|
)]
|
||||||
use crate::ffi;
|
use crate::ffi;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::os::raw::{c_char, c_int};
|
use std::os::raw::{c_char, c_int};
|
||||||
@ -8,16 +15,16 @@ use std::ptr::NonNull;
|
|||||||
/// on it. If constructed from a rust string, `sqlite3_malloc` is used.
|
/// on it. If constructed from a rust string, `sqlite3_malloc` is used.
|
||||||
///
|
///
|
||||||
/// It has identical representation to a nonnull `*mut c_char`, so you can use
|
/// It has identical representation to a nonnull `*mut c_char`, so you can use
|
||||||
/// it transparently as one. It's nonnull, so Option<SqliteMallocString> is a
|
/// it transparently as one. It's nonnull, so Option<SqliteMallocString> can be
|
||||||
/// nullable one.
|
/// used for nullable ones (it's still just one pointer).
|
||||||
///
|
///
|
||||||
/// Note that this is for Strings we manage that are owned by SQLite, like
|
/// Most strings shouldn't use this! Only places where the string needs to be
|
||||||
/// `sqlite3_extended_sql` results, some error message pointers. Most strings
|
/// freed with `sqlite3_free`. This includes `sqlite3_extended_sql` results,
|
||||||
/// are not this! Misuse is extremely dangerous!
|
/// some error message pointers... Note that misuse is extremely dangerous!
|
||||||
///
|
///
|
||||||
/// Note that this is not a lossless interface. Incoming strings with internal
|
/// Note that this is *not* a lossless interface. Incoming strings with internal
|
||||||
/// NULs are modified, and outgoing strings which are non-UTF8 are modified.
|
/// NULs are modified, and outgoing strings which are non-UTF8 are modified.
|
||||||
/// This seems unavoidable.
|
/// This seems unavoidable -- it tries very hard to not panic.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub(crate) struct SqliteMallocString {
|
pub(crate) struct SqliteMallocString {
|
||||||
ptr: NonNull<c_char>,
|
ptr: NonNull<c_char>,
|
||||||
@ -93,7 +100,7 @@ impl SqliteMallocString {
|
|||||||
/// call `handle_alloc_error` which aborts the program after calling a
|
/// call `handle_alloc_error` which aborts the program after calling a
|
||||||
/// global hook.
|
/// global hook.
|
||||||
///
|
///
|
||||||
/// This means it's safe to use in extern "C" functions outside of
|
/// This means it's safe to use in extern "C" functions even outside of
|
||||||
/// catch_unwind.
|
/// catch_unwind.
|
||||||
pub(crate) fn from_str(s: &str) -> Self {
|
pub(crate) fn from_str(s: &str) -> Self {
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
Loading…
Reference in New Issue
Block a user