Struct Equation

Source
pub struct Equation { /* private fields */ }
Expand description

A single equation.

§Examples

The Equation struct is designed to be added to an Align object. Creating one is as simple as using the constructor.

let eq = Equation::new("y &= mx + c");

For convenience, you can also convert from a &str to an Equation using into().

let eq: Equation = "y &= mx + c".into();

You can also assign a label to an equation so it can be referenced later.

eq.label("basic-linear-equation");

Implementations§

Source§

impl Equation

Source

pub fn new<S: AsRef<str>>(src: S) -> Equation

Create a new Equation.

Source

pub fn with_label(label: &str, text: &str) -> Equation

Create an equation which has a label.

Examples found in repository?
examples/complex.rs (line 36)
29fn first_section() -> Section {
30    let mut section_1 = Section::new("Introduction");
31    section_1.push("This is an example paragraph.");
32
33    let mut equations = Align::new();
34    equations
35        .push("y &= mx + c")
36        .push(Equation::with_label("quadratic", "y &= a x^2 + bx + c"));
37
38    section_1
39        .push("Please refer to the equations below:")
40        .push(equations);
41
42    let mut objectives = List::new(ListKind::Enumerate);
43    objectives
44        .push(r"Demonstrate how to use the \textit{latex} library.")
45        .push("Create a reasonably complex document")
46        .push("???")
47        .push("PROFIT!");
48
49    section_1.push("Here are our objectives:").push(objectives);
50
51    section_1
52}
Source

pub fn label(&mut self, name: &str) -> &mut Self

Give the equation a label.

Source

pub fn text(&mut self, src: &str) -> &mut Self

Set the equation’s text.

Source

pub fn not_numbered(&mut self) -> &mut Self

Set whether the \nonumber command should be used to ignore numbering for this equation.

Source

pub fn get_text(&self) -> &str

Get the equation’s text.

Source

pub fn get_label(&self) -> Option<&str>

Get the equation label, if there is one.

Source

pub fn is_numbered(&self) -> bool

Is this equation numbered?

Trait Implementations§

Source§

impl Clone for Equation

Source§

fn clone(&self) -> Equation

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 Equation

Source§

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

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

impl Default for Equation

Source§

fn default() -> Equation

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

impl<'a> From<&'a str> for Equation

Source§

fn from(other: &'a str) -> Equation

Converts to this type from the input type.
Source§

impl PartialEq for Equation

Source§

fn eq(&self, other: &Equation) -> 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 StructuralPartialEq for Equation

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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