Attribute Macro icu_provider::data_struct
source · [−]#[data_struct]
Expand description
The #[data_struct]
attribute should be applied to all types intended
for use in a DataStruct
. It does the following things:
Apply #[derive(Yokeable, ZeroFrom)]
. TheZeroFrom
derive can be customized with#[zerofrom(clone)]
on non-ZeroFrom fields.
In addition, the attribute can be used to implement DataMarker
and/or ResourceMarker
by adding symbols with optional key strings:
use icu_provider::prelude::*;
use std::borrow::Cow;
#[icu_provider::data_struct(
FooV1Marker,
BarV1Marker = "demo/bar@1",
BazV1Marker = "demo/baz@1"
)]
pub struct FooV1<'data> {
message: Cow<'data, str>,
};
// Note: FooV1Marker implements `DataMarker` but not `ResourceMarker`.
// The other two implement `ResourceMarker`.
assert_eq!(BarV1Marker::KEY.get_path(), "demo/bar@1");
assert_eq!(BazV1Marker::KEY.get_path(), "demo/baz@1");
If the #[crabbake(path = ...)]
attribute is present on the data struct, this will also
implement it on the markers.