Skip to content

Commit

Permalink
Add build_fields as ergonomic shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
voidentente committed Aug 6, 2024
1 parent 709ff5e commit 191dda6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ impl Field {
self
}

/// Ergonomic shortcut for building some inner fields
pub fn build_fields(&mut self, builder: impl FnOnce(&mut Fields)) -> &mut Self {
let mut fields = Fields::default();
builder(&mut fields);
self.fields = Some(fields);
self
}

/// Get the metadata of this field
pub fn get_meta(&self) -> &str {
self.meta.as_str()
Expand Down

0 comments on commit 191dda6

Please sign in to comment.