pub struct FieldName(/* private fields */);Expand description
A single dotted path (e.g. "database.url" or "a").
Created for you by Foo::fields().some_field().
Implementations§
Source§impl FieldName
impl FieldName
Sourcepub fn static_lit(lit: &'static str) -> Self
pub fn static_lit(lit: &'static str) -> Self
Build a Field from a &'static str literal with zero allocation.
Sourcepub fn from_string(s: String) -> Self
pub fn from_string(s: String) -> Self
Build a Field from an owned String (one allocation already paid).
Sourcepub fn join(prefix: &str, key: &'static str) -> Self
pub fn join(prefix: &str, key: &'static str) -> Self
Append key to the (possibly empty) prefix.
Examples found in repository?
examples/fields.rs (line 7)
7 a: i64,
8 bar: Bar,
9}
10
11#[derive(Fields, Serialize, Deserialize, Debug, Clone)]
12struct Bar {
13 c: String,
14 b: Baz,
15 z: Baz,
16}
17#[derive(Fields, Serialize, Deserialize, Debug, Clone)]
18struct Baz {
19 d: String,
20}
21#[derive(Fields)]
22pub struct Vec2(pub f32, pub f32);
23
24#[derive(Fields)]
25pub enum Message {
26 Quit, // "Quit"
27 Move(i32, i32), // "Move.item0", "Move.item1"
28 Write { textMore examples
examples/watch.rs (line 7)
7 a: i64,
8 bar: Bar,
9}
10
11#[derive(Fields, Serialize, Deserialize, Debug, Clone)]
12struct Bar {
13 c: String,
14 b: Baz,
15}
16#[derive(Fields, Serialize, Deserialize, Debug, Clone)]
17struct Baz {
18 dexamples/complex.rs (line 15)
15 street: String,
16 city: String,
17}
18
19#[derive(Diff, Fields, Clone, Debug, Serialize, Deserialize)]
20pub struct Account {
21 id: u32,
22 username: String,
23 password: String,
24 roles: HashSet<String>,
25 preferences: HashMap<String, String>,
26 address: Address,
27}
28
29impl PartialEq for Account {
30 fn eq(&self, other: &Self) -> bool {
31 self.id == other.id
32 }
33}
34impl Eq for Account {}
35impl Hash for Account {
36 fn hash<H: Hasher>(&self, s: &mut H) {
37 self.id.hash(s)
38 }
39}
40
41#[derive(Diff, Fields, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
42pub struct Company {
43 name: String,
44 staffTrait Implementations§
impl Eq for FieldName
impl StructuralPartialEq for FieldName
Auto Trait Implementations§
impl Freeze for FieldName
impl RefUnwindSafe for FieldName
impl Send for FieldName
impl Sync for FieldName
impl Unpin for FieldName
impl UnwindSafe for FieldName
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