Struct unsegen_jsonviewer::json_ext::Object [−][src]
pub struct Object { /* fields omitted */ }
Expand description
A binary tree implementation of a string -> JsonValue
map. You normally don’t
have to interact with instances of Object
, much more likely you will be
using the JsonValue::Object
variant, which wraps around this struct.
Implementations
impl Object
[src]
impl Object
[src]pub fn new() -> Object
[src]
pub fn new() -> Object
[src]Create a new, empty instance of Object
. Empty Object
performs no
allocation until a value is inserted into it.
pub fn with_capacity(capacity: usize) -> Object
[src]
pub fn with_capacity(capacity: usize) -> Object
[src]Create a new Object
with memory preallocated for capacity
number
of entries.
pub fn insert(&mut self, key: &str, value: JsonValue)
[src]
pub fn insert(&mut self, key: &str, value: JsonValue)
[src]Insert a new entry, or override an existing one. Note that key
has
to be a &str
slice and not an owned String
. The internals of
Object
will handle the heap allocation of the key if needed for
better performance.
pub fn override_last(&mut self, value: JsonValue)
[src]
Was only meant for internal use
pub fn get(&self, key: &str) -> Option<&JsonValue>
[src]
pub fn get_mut(&mut self, key: &str) -> Option<&mut JsonValue>
[src]
pub fn remove(&mut self, key: &str) -> Option<JsonValue>
[src]
pub fn remove(&mut self, key: &str) -> Option<JsonValue>
[src]Attempts to remove the value behind key
, if successful
will return the JsonValue
stored behind the key
.
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn iter(&self) -> Iter<'_>
[src]
pub fn iter_mut(&mut self) -> IterMut<'_>
[src]
Trait Implementations
impl<'a> Index<&'a str> for Object
[src]
impl<'a> Index<&'a str> for Object
[src]Implements indexing by &str
to easily access object members:
Example
let value = object!{ "foo" => "bar" }; if let JsonValue::Object(object) = value { assert!(object["foo"] == "bar"); }
impl<'a> IndexMut<&'a str> for Object
[src]
impl<'a> IndexMut<&'a str> for Object
[src]Implements mutable indexing by &str
to easily modify object members:
Example
let value = object!{}; if let JsonValue::Object(mut object) = value { object["foo"] = 42.into(); assert!(object["foo"] == 42); }
Auto Trait Implementations
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more