[][src]Struct sibyl::Rows

pub struct Rows<'s> { /* fields omitted */ }

Result set of a query

Methods

impl<'s> Rows<'s>[src]

pub fn next(&self) -> Result<Option<Row>>[src]

Returns the next row in the SELECT's result set.

Example

let stmt = conn.prepare("
    SELECT street_address, postal_code, city, state_province
      FROM hr.locations
     WHERE country_id = :id
  ORDER BY location_id
")?;
let rows = stmt.query(&[ &"CA" ])?;
let mut res = Vec::new();
while let Some( row ) = rows.next()? {
    // &str does not live long enough to be useful for
    // the `street_address`
    let street_address : Option<String> = row.get(0)?;
    let postal_code    : Option<&str>   = row.get(1)?;
    let city           : Option<&str>   = row.get(2)?;
    let state_province : Option<&str>   = row.get(3)?;
    let city_address = format!("{} {} {}",
        city           .unwrap_or_default(),
        state_province .unwrap_or_default(),
        postal_code    .unwrap_or_default(),
    );
    res.push((street_address.unwrap_or_default(), city_address));
}

assert_eq!(2, res.len());
assert_eq!("Toronto Ontario M5V 2L7",  res[0].1);
assert_eq!("Whitehorse Yukon YSW 9T2", res[1].1);

Auto Trait Implementations

impl<'s> !Send for Rows<'s>

impl<'s> !Sync for Rows<'s>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]