extruct_core/lib.rs
1/// A trait that provides access to the list of named fields of a struct
2/// represented as string literals.
3///
4/// This trait is not intended to be implemented manually. Instead,
5/// use the `#[derive(Fields)]` macro from `extruct` library.
6#[cfg(any(feature = "fields", doc))]
7pub trait Fields {
8 /// Get the list of names of fields of the struct.
9 fn fields() -> &'static [&'static str];
10}
11
12/// A marker trait indicating that a struct which implements it
13/// has been annotated with `[extruct_from(T)]` for the given type T.
14/// It is an extension over the [`std::convert::From`](https://doc.rust-lang.org/std/convert/trait.From.html)
15/// trait and verifies that all names of the fields are preserved during
16/// conversion.
17///
18/// This trait is not intended to be implemented manually. Its whole
19/// purpose is to indicate the use of the `extruct_from` macro on a
20/// struct that implements it.
21#[cfg(any(feature = "extruct_from", doc))]
22pub trait ExtructedFrom<T>: std::convert::From<T> {}