Struct minimad::Compound

source ·
pub struct Compound<'s> {
    pub src: &'s str,
    pub bold: bool,
    pub italic: bool,
    pub code: bool,
    pub strikeout: bool,
}
Expand description

a Compound is a part of a line with a consistent styling. It can be part of word, several words, some inline code, or even the whole line.

Fields§

§src: &'s str§bold: bool§italic: bool§code: bool§strikeout: bool

Implementations§

source§

impl<'s> Compound<'s>

source

pub fn raw_str(src: &'s str) -> Compound<'s>

make a raw unstyled compound Involves no parsing

source

pub fn set_str(&mut self, src: &'s str)

change the content but keeps the style arguments

source

pub fn set_attributes_from(&mut self, other: &Compound<'_>)

change the attributes by taking the values from the other compound, keeping the str

source

pub fn sub(&self, r_start: usize, r_end: usize) -> Compound<'s>

return a sub part of the compound, with the same styling r_start is relative, that is 0 is the index of the first byte of this compound.

source

pub fn sub_chars(&self, r_start: usize, r_end: usize) -> Compound<'s>

return a sub part of the compound, with the same styling r_start is relative, that is 0 is the index of the first char of this compound.

The difference with sub is that this method is unicode aware and counts the chars instead of asking for the bytes

source

pub fn tail(&self, r_start: usize) -> Compound<'s>

return a sub part at end of the compound, with the same styling r_start is relative, that is if you give 0 you get a clone of this compound

source

pub fn tail_chars(&self, r_start: usize) -> Compound<'s>

return a sub part at end of the compound, with the same styling r_start is relative, that is if you give 0 you get a clone of this compound

The difference with tail is that this method is unicode aware and counts the chars instead of asking for the bytes

source

pub fn cut_tail(&mut self, tail_size: usize) -> Compound<'s>

source

pub fn raw_part(src: &'s str, start: usize, end: usize) -> Compound<'s>

source

pub fn new( src: &'s str, start: usize, end: usize, bold: bool, italic: bool, code: bool, strikeout: bool ) -> Compound<'s>

source

pub fn bold(self) -> Compound<'s>

source

pub fn italic(self) -> Compound<'s>

source

pub fn code(self) -> Compound<'s>

source

pub fn strikeout(self) -> Compound<'s>

source

pub fn set_bold(&mut self, bold: bool)

source

pub fn set_italic(&mut self, italic: bool)

source

pub fn set_code(&mut self, code: bool)

source

pub fn set_strikeout(&mut self, strikeout: bool)

source

pub fn as_str(&self) -> &'s str

source

pub fn char_length(&self) -> usize

source

pub fn is_empty(&self) -> bool

Trait Implementations§

source§

impl<'s> Clone for Compound<'s>

source§

fn clone(&self) -> Compound<'s>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Compound<'_>

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for Compound<'_>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'s> Hash for Compound<'s>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'s> PartialEq for Compound<'s>

source§

fn eq(&self, other: &Compound<'s>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> Eq for Compound<'s>

source§

impl<'s> StructuralPartialEq for Compound<'s>

Auto Trait Implementations§

§

impl<'s> Freeze for Compound<'s>

§

impl<'s> RefUnwindSafe for Compound<'s>

§

impl<'s> Send for Compound<'s>

§

impl<'s> Sync for Compound<'s>

§

impl<'s> Unpin for Compound<'s>

§

impl<'s> UnwindSafe for Compound<'s>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.