pub struct Obj(pub Vec<(String, Js)>);Expand description
An object: fields in insertion order. Setting an existing field keeps its position, as in JavaScript.
Tuple Fields§
§0: Vec<(String, Js)>Implementations§
Source§impl Obj
impl Obj
pub fn new() -> Obj
Sourcepub fn set(&mut self, key: &str, value: impl Into<Js>) -> &mut Obj
pub fn set(&mut self, key: &str, value: impl Into<Js>) -> &mut Obj
Appends or replaces key (keeping its position when it exists).
Sourcepub fn with_opt<T: Into<Js>>(self, key: &str, value: Option<T>) -> Obj
pub fn with_opt<T: Into<Js>>(self, key: &str, value: Option<T>) -> Obj
Sets key only when value is Some.
pub fn get(&self, key: &str) -> Option<&Js>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Js>
pub fn remove(&mut self, key: &str) -> Option<Js>
pub fn num(&self, key: &str) -> f64
pub fn str(&self, key: &str) -> Option<&str>
pub fn bool(&self, key: &str) -> bool
Trait Implementations§
impl StructuralPartialEq for Obj
Auto Trait Implementations§
impl Freeze for Obj
impl RefUnwindSafe for Obj
impl Send for Obj
impl Sync for Obj
impl Unpin for Obj
impl UnsafeUnpin for Obj
impl UnwindSafe for Obj
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more