mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-20 21:09:31 +08:00
Merge remote-tracking branch 'origin/master' into ptr_as_ptr
This commit is contained in:
@@ -177,7 +177,7 @@ impl FromSql for std::sync::Arc<str> {
|
||||
impl FromSql for Vec<u8> {
|
||||
#[inline]
|
||||
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
||||
value.as_blob().map(|b| b.to_vec())
|
||||
value.as_blob().map(<[u8]>::to_vec)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ impl FromSql for i128 {
|
||||
#[inline]
|
||||
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
||||
let bytes = <[u8; 16]>::column_result(value)?;
|
||||
Ok(i128::from_be_bytes(bytes) ^ (1i128 << 127))
|
||||
Ok(i128::from_be_bytes(bytes) ^ (1_i128 << 127))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,7 @@ impl FromSql for OffsetDateTime {
|
||||
len if len <= 19 => {
|
||||
// TODO YYYY-MM-DDTHH:MM:SS
|
||||
PrimitiveDateTime::parse(s, &PRIMITIVE_SHORT_DATE_TIME_FORMAT)
|
||||
.map(|d| d.assume_utc())
|
||||
.map(PrimitiveDateTime::assume_utc)
|
||||
}
|
||||
_ if s.as_bytes()[19] == b':' => {
|
||||
// legacy
|
||||
@@ -56,7 +56,7 @@ impl FromSql for OffsetDateTime {
|
||||
_ if s.as_bytes()[19] == b'.' => OffsetDateTime::parse(s, &OFFSET_DATE_TIME_FORMAT)
|
||||
.or_else(|err| {
|
||||
PrimitiveDateTime::parse(s, &PRIMITIVE_DATE_TIME_FORMAT)
|
||||
.map(|d| d.assume_utc())
|
||||
.map(PrimitiveDateTime::assume_utc)
|
||||
.map_err(|_| err)
|
||||
}),
|
||||
_ => OffsetDateTime::parse(s, &OFFSET_SHORT_DATE_TIME_FORMAT),
|
||||
|
@@ -47,7 +47,7 @@ impl From<i128> for Value {
|
||||
fn from(i: i128) -> Value {
|
||||
// We store these biased (e.g. with the most significant bit flipped)
|
||||
// so that comparisons with negative numbers work properly.
|
||||
Value::Blob(i128::to_be_bytes(i ^ (1i128 << 127)).to_vec())
|
||||
Value::Blob(i128::to_be_bytes(i ^ (1_i128 << 127)).to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ where
|
||||
impl Value {
|
||||
/// Returns SQLite fundamental datatype.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn data_type(&self) -> Type {
|
||||
match *self {
|
||||
Value::Null => Type::Null,
|
||||
|
@@ -22,6 +22,7 @@ pub enum ValueRef<'a> {
|
||||
impl ValueRef<'_> {
|
||||
/// Returns SQLite fundamental datatype.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn data_type(&self) -> Type {
|
||||
match *self {
|
||||
ValueRef::Null => Type::Null,
|
||||
|
Reference in New Issue
Block a user