[][src]Struct pickledb::PickleDbListExtender

pub struct PickleDbListExtender<'a> { /* fields omitted */ }

A struct for extending PickleDB lists and adding more items to them

Methods

impl<'a> PickleDbListExtender<'a>[src]

pub fn ladd<V>(&mut self, value: &V) -> PickleDbListExtender where
    V: Serialize
[src]

Add a single item to an existing list.

As mentioned before, the lists are heterogeneous, meaning a single list can contain items of different types. That means that the item can be of any type that is serializable. That includes all primitive types, vectors, tuples and every struct that has the #[derive(Serialize, Deserialize) attribute. The method returns another PickleDbListExtender object that enables to continue adding items to the list.

Arguments

  • value - a reference of the item to add to the list

Examples

// create a new list
db.lcreate("list1").unwrap()

// add items of different types to the list
  .ladd(&100)
  .ladd(&String::from("my string"))
  .ladd(&vec!["aa", "bb", "cc"]);

pub fn lextend<'i, V, I>(&mut self, seq: I) -> PickleDbListExtender where
    V: 'i + Serialize,
    I: IntoIterator<Item = &'i V>, 
[src]

Add multiple items to an existing list.

As mentioned before, the lists are heterogeneous, meaning a single list can contain items of different types. That means that the item can be of any type that is serializable. That includes all primitive types, vectors, tuples and every struct that has the #[derive(Serialize, Deserialize) attribute. This method adds multiple items to the list, but since they're in a vector that means all of them are of the same type. Of course it doesn't mean that the list cannot contain items of other types as well, as you can see in the example below. The method returns another PickleDbListExtender object that enables to continue adding items to the list.

Arguments

  • seq - an iterator containing references to the new items to add to the list

Examples

// create a new list
db.lcreate("list1");

// add a bunch of numbers to the list
db.lextend("list1", &vec![100, 200, 300]).unwrap()

// add a bunch of strings to the list
  .lextend(&vec!["aa", "bb", "cc"]);

// now the list contains 6 items and looks like this: [100, 200, 300, "aa, "bb", "cc"]

Auto Trait Implementations

impl<'a> RefUnwindSafe for PickleDbListExtender<'a>

impl<'a> Send for PickleDbListExtender<'a>

impl<'a> Sync for PickleDbListExtender<'a>

impl<'a> Unpin for PickleDbListExtender<'a>

impl<'a> !UnwindSafe for PickleDbListExtender<'a>

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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.