Expand description
Part
s are used as annotations for formatted strings. For example, a string like
Alice, Bob
could assign a NAME
part to the substrings Alice
and Bob
, and a
PUNCTUATION
part to ,
. This allows for example to apply styling only to names.
Part
contains two fields, whose usage is left up to the producer of the Writeable
.
Conventionally, the category
field will identify the formatting logic that produces
the string/parts, whereas the value
field will have semantic meaning. NAME
and
PUNCTUATION
could thus be defined as
const NAME: Part = Part { category: "userlist", value: "name" };
const PUNCTUATION: Part = Part { category: "userlist", value: "punctuation" };
That said, consumers should not usually have to inspect Part
internals. Instead,
formatters should expose the Part
s they produces as constants.
Fields
category: &'static str
value: &'static str
Trait Implementations
impl Copy for Part
impl StructuralPartialEq for Part
Auto Trait Implementations
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnwindSafe for Part
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more