mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Cow<str> now implements ToSql.
This commit is contained in:
parent
a7479488b8
commit
5351d88bc0
@ -1,3 +1,4 @@
|
||||
use std::borrow::Cow;
|
||||
use super::{Null, Value, ValueRef};
|
||||
use Result;
|
||||
|
||||
@ -149,6 +150,12 @@ impl<T: ToSql> ToSql for Option<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToSql for Cow<'a, str> {
|
||||
fn to_sql(&self) -> Result<ToSqlOutput> {
|
||||
Ok(ToSqlOutput::from(self.as_ref()))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::ToSql;
|
||||
@ -165,4 +172,16 @@ mod test {
|
||||
is_to_sql::<u16>();
|
||||
is_to_sql::<u32>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cow_str() {
|
||||
use std::borrow::Cow;
|
||||
let s = "str";
|
||||
let cow = Cow::Borrowed(s);
|
||||
let r = cow.to_sql();
|
||||
assert!(r.is_ok());
|
||||
let cow = Cow::Owned::<str>(String::from(s));
|
||||
let r = cow.to_sql();
|
||||
assert!(r.is_ok());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user