Struct Part

struct Part { ... }

Parts 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

# use writeable::Part;
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 Parts they produces as constants.

Fields

category: &'static str
value: &'static str

Implementations

impl Part

impl Clone for Part

fn clone(self: &Self) -> Part

impl Copy for Part

impl Debug for Part

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for Part

impl PartialEq for Part

fn eq(self: &Self, other: &Part) -> bool

impl RefUnwindSafe for Part

impl Send for Part

impl StructuralPartialEq for Part

impl Sync for Part

impl Unpin for Part

impl UnsafeUnpin for Part

impl UnwindSafe for Part

impl<T> Any for Part

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Part

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Part

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Part

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Part

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Part

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Part

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Part

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Part

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>