pub trait KeyLookup {
const LEN: usize;
const NAMES: &'static [&'static str];
// Required method
fn name_to_index(value: &str) -> Option<usize>;
}Expand description
The capability to look up top level field names and convert to indices
This trait is derived together with crate::TreeKey.
use miniconf::{KeyLookup, TreeKey};
#[derive(TreeKey)]
struct S {
foo: u32,
bar: [u16; 2],
}
assert_eq!(S::LEN, 2);
assert_eq!(S::NAMES[1], "bar");
assert_eq!(S::name_to_index("bar").unwrap(), 1);Required Associated Constants§
Required Methods§
sourcefn name_to_index(value: &str) -> Option<usize>
fn name_to_index(value: &str) -> Option<usize>
Convert a top level node name to a node index.
The details of the mapping and the usize index values
are an implementation detail and only need to be stable at runtime.
This is used by impl Key for &str.
Object Safety§
This trait is not object safe.