#[non_exhaustive]pub struct Derive {
pub path: String,
pub cfg: Option<String>,
}Expand description
A derive written on a generated struct or enum.
A bare path derives unconditionally. with_cfg puts the derive behind a
cfg predicate, which is how an optional dependency reaches generated code.
Module::with_derives sets them for every item; each item’s own with_derives adds to that.
use layline_codegen::Derive;
let always: Derive = "Copy".into();
let gated = Derive::new("serde::Serialize").with_cfg("feature = \"serde\"");
assert_eq!(always.cfg, None);
assert_eq!(gated.path, "serde::Serialize");Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.path: StringThe derive path, such as serde::Serialize.
cfg: Option<String>The cfg predicate the derive sits behind, such as feature = "serde".
Implementations§
Trait Implementations§
impl Eq for Derive
impl StructuralPartialEq for Derive
Auto Trait Implementations§
impl Freeze for Derive
impl RefUnwindSafe for Derive
impl Send for Derive
impl Sync for Derive
impl Unpin for Derive
impl UnsafeUnpin for Derive
impl UnwindSafe for Derive
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