pub struct Struct { /* private fields */ }Expand description
An in-memory representation of an Ion Struct
use ion_rs::{Element, ion_struct};
let struct_ = ion_struct! {
"foo": 1,
"bar": true,
"baz": "hello"
};
assert_eq!(struct_.len(), 3);
assert_eq!(struct_.get("baz"), Some(&Element::string("hello")));Implementations§
Source§impl Struct
impl Struct
pub fn builder() -> StructBuilder
pub fn clone_builder(&self) -> StructBuilder
Sourcepub fn fields(&self) -> impl Iterator<Item = (&Symbol, &Element)>
pub fn fields(&self) -> impl Iterator<Item = (&Symbol, &Element)>
Returns an iterator over the field name/value pairs in this Struct.
pub fn iter(&self) -> FieldIterator<'_>
Sourcepub fn get<A: AsSymbolRef>(&self, field_name: A) -> Option<&Element>
pub fn get<A: AsSymbolRef>(&self, field_name: A) -> Option<&Element>
Returns the value associated with the specified field name.
If more than one field in this struct has that name, this method will return the value of
the last field with that name. To access other fields with the same name, see
get_all.
Trait Implementations§
Source§impl<K, V> FromIterator<(K, V)> for Struct
impl<K, V> FromIterator<(K, V)> for Struct
Source§fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
Returns an owned struct from the given iterator of field names/values.
Source§impl<'a> IntoIterator for &'a Struct
impl<'a> IntoIterator for &'a Struct
Source§impl IntoIterator for Struct
impl IntoIterator for Struct
Auto Trait Implementations§
impl Freeze for Struct
impl RefUnwindSafe for Struct
impl Send for Struct
impl Sync for Struct
impl Unpin for Struct
impl UnsafeUnpin for Struct
impl UnwindSafe for Struct
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<V> IntoAnnotatedElement for V
impl<V> IntoAnnotatedElement for V
Source§fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
Converts the value into an Element with the specified annotations.
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more