pub struct Field { /* private fields */ }
Expand description
The metadata and inner Fields
of a field.
Implementations§
Source§impl Field
impl Field
Sourcepub fn new(doc: impl Into<String>, fields: Option<Fields>) -> Self
pub fn new(doc: impl Into<String>, fields: Option<Fields>) -> Self
Create a new field metadata from parts.
Sourcepub fn doc_mut(&mut self) -> &mut String
pub fn doc_mut(&mut self) -> &mut String
Get a mutable reference to the documentation metadata of this field.
Sourcepub fn with_doc(&mut self, doc: impl Into<String>) -> &mut Self
pub fn with_doc(&mut self, doc: impl Into<String>) -> &mut Self
Set the documentation metadata of this field.
let mut field = Field::empty();
assert_eq!(field.doc(), "");
field.with_doc("some meta");
assert_eq!(field.doc(), "some meta");
Sourcepub fn fields(&self) -> Option<&Fields>
pub fn fields(&self) -> Option<&Fields>
Get a shared reference to the inner fields of this field, if it has any.
Sourcepub fn fields_mut(&mut self) -> Option<&mut Fields>
pub fn fields_mut(&mut self) -> Option<&mut Fields>
Get a mutable reference to the inner fields of this field, if it has any.
Sourcepub fn has_fields(&self) -> bool
pub fn has_fields(&self) -> bool
Return whether this field has inner fields.
let mut field = Field::empty();
assert!(!field.has_fields());
field.with_fields(Some(Fields::default()));
assert!(field.has_fields());
Sourcepub fn with_fields(&mut self, fields: Option<Fields>) -> &mut Self
pub fn with_fields(&mut self, fields: Option<Fields>) -> &mut Self
Set the inner fields of this field.
let mut field = Field::empty();
assert!(!field.has_fields());
field.with_fields(Some(Fields::default()));
assert!(field.has_fields());
field.with_fields(None);
assert!(!field.has_fields());
Sourcepub fn build_fields(&mut self, builder: impl FnOnce(&mut Fields)) -> &mut Self
pub fn build_fields(&mut self, builder: impl FnOnce(&mut Fields)) -> &mut Self
Ergonomic shortcut for building some inner fields.
let mut field = Field::empty();
field.build_fields(|fields| {
fields.field("inner field");
});
assert_eq!(field.fields().map(|fields| fields.contains("inner field")), Some(true));
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Field
impl<'de> Deserialize<'de> for Field
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.