pub struct Part {
pub category: &'static str,
pub value: &'static str,
}
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
Implementations§
source§impl Part
impl Part
sourcepub const ERROR: Part = _
pub const ERROR: Part = _
A part that should annotate error segments in TryWriteable
output.
For an example, see TryWriteable
.
Trait Implementations§
impl Copy for Part
impl StructuralPartialEq for Part
Auto Trait Implementations§
impl Freeze for Part
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnwindSafe for Part
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)