Struct build_html::TableRow

source ·
pub struct TableRow { /* private fields */ }
Expand description

A builder for more manual control over individual table elements

Example

let row = TableRow::new()
    .with_attributes([("id", "my-row")])
    .with_cell(TableCell::new(TableCellType::Header).with_raw("Header"))
    .with_cell(TableCell::default().with_raw(1))
    .to_html_string();

assert_eq!(row, r#"<tr id="my-row"><th>Header</th><td>1</td></tr>"#);

Implementations§

source§

impl TableRow

source

pub fn new() -> Self

Create a new, empty TableRow

source

pub fn with_attributes<A, S>(self, attributes: A) -> Selfwhere A: IntoIterator<Item = (S, S)>, S: ToString,

Set the attributes for this row.

Note that this operation overrides all previous invocations of with_attributes.

Example
let out = TableRow::new()
    .with_attributes([("id", "first-row"), ("class", "table-rows")])
    .with_cell(TableCell::default())
    .to_html_string();
assert_eq!(out, r#"<tr id="first-row" class="table-rows"><td></td></tr>"#);
source

pub fn add_cell(&mut self, cell: TableCell)

Add a cell to this row.

Example
let mut out = TableRow::new();
out.add_cell(TableCell::default().with_paragraph("Hello, World!"));
assert_eq!(out.to_html_string(), "<tr><td><p>Hello, World!</p></td></tr>");
source

pub fn with_cell(self, cell: TableCell) -> Self

Nest the given cell inside this row

Example
let out = TableRow::new()
    .with_cell(TableCell::default().with_paragraph("Hello, World!"))
    .to_html_string();
assert_eq!(out, "<tr><td><p>Hello, World!</p></td></tr>");

Trait Implementations§

source§

impl Debug for TableRow

source§

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

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

impl Default for TableRow

source§

fn default() -> TableRow

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

impl<T> From<T> for TableRowwhere T: IntoIterator, T::Item: Display,

source§

fn from(elements: T) -> Self

Converts to this type from the input type.
source§

impl Html for TableRow

source§

fn to_html_string(&self) -> String

Convert this element into an HTML string Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.