[−][src]Struct roa_core::Bucket
A wrapper of HashMap<String, String>
, method get
return a Variable
.
Example
use roa_core::{Bucket, Variable}; let mut bucket = Bucket::new(); assert!(bucket.get("id").is_none()); assert!(bucket.insert("id", "1").is_none()); assert_eq!(1, bucket.get("id").unwrap().parse().unwrap()); assert_eq!(1, bucket.insert("id", "2").unwrap().parse().unwrap());
Methods
impl Bucket
[src]
pub fn new() -> Self
[src]
Construct an empty Bucket.
pub fn insert<'a>(
&mut self,
name: &'a str,
value: impl ToString
) -> Option<Variable<'a>>
[src]
&mut self,
name: &'a str,
value: impl ToString
) -> Option<Variable<'a>>
Inserts a key-value pair into the bucket.
If the bucket did not have this key present, None
is returned.
If the bucket did have this key present, the value is updated, and the old value is returned.
Example
use roa_core::{Bucket, Variable}; let mut bucket = Bucket::new(); assert!(bucket.insert("id", "1").is_none()); assert_eq!(1, bucket.insert("id", "2").unwrap().parse().unwrap());
pub fn get<'a>(&self, name: &'a str) -> Option<Variable<'a>>
[src]
If the bucket did not have this key present, None
is returned.
If the bucket did have this key present, the key-value pair will be returned as a Variable
Example
use roa_core::{Bucket, Variable}; let mut bucket = Bucket::new(); assert!(bucket.get("id").is_none()); bucket.insert("id", "1"); assert_eq!(1, bucket.get("id").unwrap().parse().unwrap());
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Bucket
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnwindSafe for Bucket
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,