inline_config/
get.rs

1use crate::convert::ConvertInto;
2use crate::key::AccessPath;
3
4/// A trait modeling the type compatibility.
5///
6/// A type bound `C: Get<'_, P, T>` means the data at path `P` from config `C` is compatible with and can be converted into `T`.
7///
8/// This trait is not meant to be custom implemented.
9/// The trait bound is satisfied by macro-generated implementations of internal helper traits.
10pub trait Get<'c, P, T> {
11    fn get(&'c self, path: P) -> T;
12}
13
14impl<'c, C, P, T> Get<'c, P, T> for C
15where
16    C: AccessPath<'c, P>,
17    C::Repr: 'c + ConvertInto<'c, T>,
18{
19    fn get(&'c self, _path: P) -> T {
20        self.access_path().convert_into()
21    }
22}