[][src]Struct genpdf::style::StyledStr

pub struct StyledStr<'s> {
    pub s: &'s str,
    pub style: Style,
}

A &str with a Style annotation.

Example

use genpdf::style;
let ss1 = style::StyledStr::new("bold", style::Effect::Bold);
let ss2 = style::StyledStr::new("red", style::Color::Rgb(255, 0, 0));

Fields

s: &'s str

The annotated string.

style: Style

The style annotation.

Implementations

impl<'s> StyledStr<'s>[src]

pub fn new(s: &'s str, style: impl Into<Style>) -> StyledStr<'s>[src]

Creates a new styled string from the given string and style.

pub fn width(&self, font_cache: &FontCache) -> Mm[src]

Calculates the width of the this string with this style using the data in the given font cache.

If the font family is set for the style, it must have been created by the given FontCache.

Trait Implementations

impl<'s> Clone for StyledStr<'s>[src]

impl<'s> Debug for StyledStr<'s>[src]

impl<'s> Default for StyledStr<'s>[src]

impl<'s> From<&'s String> for StyledStr<'s>[src]

impl<'s> From<&'s StyledString> for StyledStr<'s>[src]

impl<'s> From<&'s str> for StyledStr<'s>[src]

Auto Trait Implementations

impl<'s> RefUnwindSafe for StyledStr<'s>

impl<'s> Send for StyledStr<'s>

impl<'s> Sync for StyledStr<'s>

impl<'s> Unpin for StyledStr<'s>

impl<'s> UnwindSafe for StyledStr<'s>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.