pub struct Object<'a> {
pub range: Range,
pub properties: Vec<ObjectProp<'a>>,
}
Expand description
Represents an object that may contain properties (ex. {}
, { "prop": 4 }
).
Fields§
§range: Range
§properties: Vec<ObjectProp<'a>>
Implementations§
Source§impl<'a> Object<'a>
impl<'a> Object<'a>
Sourcepub fn get(&self, name: &str) -> Option<&ObjectProp<'a>>
pub fn get(&self, name: &str) -> Option<&ObjectProp<'a>>
Gets a property value in the object by its name.
Sourcepub fn get_string(&self, name: &str) -> Option<&StringLit<'a>>
pub fn get_string(&self, name: &str) -> Option<&StringLit<'a>>
Gets a string property value from the object by name.
Returns None
when not a string or it doesn’t exist.
Sourcepub fn get_number(&self, name: &str) -> Option<&NumberLit<'a>>
pub fn get_number(&self, name: &str) -> Option<&NumberLit<'a>>
Gets a number property value from the object by name.
Returns None
when not a number or it doesn’t exist.
Sourcepub fn get_boolean(&self, name: &str) -> Option<&BooleanLit>
pub fn get_boolean(&self, name: &str) -> Option<&BooleanLit>
Gets a boolean property value from the object by name.
Returns None
when not a boolean or it doesn’t exist.
Sourcepub fn get_object(&self, name: &str) -> Option<&Object<'a>>
pub fn get_object(&self, name: &str) -> Option<&Object<'a>>
Gets an object property value from the object by name.
Returns None
when not an object or it doesn’t exist.
Sourcepub fn get_array(&self, name: &str) -> Option<&Array<'a>>
pub fn get_array(&self, name: &str) -> Option<&Array<'a>>
Gets an array property value from the object by name.
Returns None
when not an array or it doesn’t exist.
Sourcepub fn take(&mut self, name: &str) -> Option<ObjectProp<'a>>
pub fn take(&mut self, name: &str) -> Option<ObjectProp<'a>>
Takes a value from the object by name.
Returns None
when it doesn’t exist.
Sourcepub fn take_string(&mut self, name: &str) -> Option<StringLit<'a>>
pub fn take_string(&mut self, name: &str) -> Option<StringLit<'a>>
Takes a string property value from the object by name.
Returns None
when not a string or it doesn’t exist.
Sourcepub fn take_number(&mut self, name: &str) -> Option<NumberLit<'a>>
pub fn take_number(&mut self, name: &str) -> Option<NumberLit<'a>>
Takes a number property value from the object by name.
Returns None
when not a number or it doesn’t exist.
Sourcepub fn take_boolean(&mut self, name: &str) -> Option<BooleanLit>
pub fn take_boolean(&mut self, name: &str) -> Option<BooleanLit>
Takes a boolean property value from the object by name.
Returns None
when not a boolean or it doesn’t exist.
Sourcepub fn take_object(&mut self, name: &str) -> Option<Object<'a>>
pub fn take_object(&mut self, name: &str) -> Option<Object<'a>>
Takes an object property value from the object by name.
Returns None
when not an object or it doesn’t exist.
Sourcepub fn take_array(&mut self, name: &str) -> Option<Array<'a>>
pub fn take_array(&mut self, name: &str) -> Option<Array<'a>>
Takes an array property value from the object by name.
Returns None
when not an array or it doesn’t exist.
Trait Implementations§
impl<'a> StructuralPartialEq for Object<'a>
Auto Trait Implementations§
impl<'a> Freeze for Object<'a>
impl<'a> RefUnwindSafe for Object<'a>
impl<'a> Send for Object<'a>
impl<'a> Sync for Object<'a>
impl<'a> Unpin for Object<'a>
impl<'a> UnwindSafe for Object<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)