TableLayoutRow

Struct TableLayoutRow 

Source
pub struct TableLayoutRow<'a> { /* private fields */ }
Expand description

A row of a table layout.

This is a helper struct for populating a TableLayout. After you have added all elements to the row using push_element or element, you can append the row to the table layout by calling push.

§Examples

With setters:

use genpdf::elements;
let mut table = elements::TableLayout::new(vec![1, 1]);
let mut row = table.row();
row.push_element(elements::Paragraph::new("Cell 1"));
row.push_element(elements::Paragraph::new("Cell 2"));
row.push().expect("Invalid table row");

Chained:

use genpdf::elements;
let table = elements::TableLayout::new(vec![1, 1])
    .row()
    .element(elements::Paragraph::new("Cell 1"))
    .element(elements::Paragraph::new("Cell 2"))
    .push()
    .expect("Invalid table row");

Implementations§

Source§

impl<'a> TableLayoutRow<'a>

Source

pub fn push_element<E: Element + 'static>(&mut self, element: E)

Adds the given element to this row.

Source

pub fn element<E: Element + 'static>(self, element: E) -> Self

Adds the given element to this row and returns the row.

Source

pub fn push(self) -> Result<(), Error>

Tries to append this row to the table.

This method fails if the number of elements in this row does not match the number of columns in the table.

Auto Trait Implementations§

§

impl<'a> Freeze for TableLayoutRow<'a>

§

impl<'a> !RefUnwindSafe for TableLayoutRow<'a>

§

impl<'a> !Send for TableLayoutRow<'a>

§

impl<'a> !Sync for TableLayoutRow<'a>

§

impl<'a> Unpin for TableLayoutRow<'a>

§

impl<'a> !UnwindSafe for TableLayoutRow<'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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.