Struct html_rs::HtmlHeadItem

source ·
pub struct HtmlHeadItem<'a> { /* private fields */ }

Implementations§

source§

impl<'a> HtmlHeadItem<'a>

source

pub fn new<S: AsRef<str>>(tag_str: S) -> HtmlHeadItem<'a>

Examples found in repository?
examples/getting_started.rs (line 7)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
fn main() {
    let title = HtmlHeadItem::new("<title>It works!</title>");
    let style = HtmlStyle::new("body { color: #000000; }");
    let script1 = HtmlScript::new(
        format!(
            r#"console.log("Hello from file {} at line {}")"#,
            file!(),
            line!(),
        )
        .as_str(),
    );

    let div = Div::builder().attr("class", "light-theme").append_child(
        P::builder()
            .attr("class", "light-theme")
            .append_child(TextContent::text("It Works!")),
    );

    let body = HtmlBody::new()
        .set_attr("lang", "en")
        .script(script1)
        .append_child(div);

    let script2 = HtmlScript::new(
        format!(
            r#"console.log("Hello from file {} at line {}")"#,
            file!(),
            line!(),
        )
        .as_str(),
    );
    let html = Html::new()
        .head(title)
        .add_style(style)
        .add_script(script2)
        .body(body);

    #[cfg(feature = "debug")]
    dbg!(&html);

    println!("{html}");
}

Trait Implementations§

source§

impl<'a> Debug for HtmlHeadItem<'a>

source§

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

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

impl<'a> Default for HtmlHeadItem<'a>

source§

fn default() -> HtmlHeadItem<'a>

Returns the “default value” for a type. Read more
source§

impl Display for HtmlHeadItem<'_>

source§

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

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

impl<'a> PartialEq for HtmlHeadItem<'a>

source§

fn eq(&self, other: &HtmlHeadItem<'a>) -> bool

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

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

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

impl<'a> Eq for HtmlHeadItem<'a>

source§

impl<'a> StructuralPartialEq for HtmlHeadItem<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for HtmlHeadItem<'a>

§

impl<'a> RefUnwindSafe for HtmlHeadItem<'a>

§

impl<'a> Send for HtmlHeadItem<'a>

§

impl<'a> Sync for HtmlHeadItem<'a>

§

impl<'a> Unpin for HtmlHeadItem<'a>

§

impl<'a> UnwindSafe for HtmlHeadItem<'a>

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> 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.