Allow getting a ValueRef out of Row and Context, fixes #259

This commit is contained in:
Thom Chiovoloni
2018-10-18 11:59:30 -07:00
parent 73d7606ebc
commit 3d82f7199a
4 changed files with 84 additions and 6 deletions

View File

@@ -52,7 +52,7 @@ impl<'a> ValueRef<'a> {
/// If `self` is case `Text`, returns the string value. Otherwise, returns
/// `Err(Error::InvalidColumnType)`.
pub fn as_str(&self) -> FromSqlResult<&str> {
pub fn as_str(&self) -> FromSqlResult<&'a str> {
match *self {
ValueRef::Text(t) => Ok(t),
_ => Err(FromSqlError::InvalidType),
@@ -61,7 +61,7 @@ impl<'a> ValueRef<'a> {
/// If `self` is case `Blob`, returns the byte slice. Otherwise, returns
/// `Err(Error::InvalidColumnType)`.
pub fn as_blob(&self) -> FromSqlResult<&[u8]> {
pub fn as_blob(&self) -> FromSqlResult<&'a [u8]> {
match *self {
ValueRef::Blob(b) => Ok(b),
_ => Err(FromSqlError::InvalidType),