Struct latex::Document
[−]
[src]
pub struct Document { pub class: DocumentClass, pub preamble: Preamble, pub elements: Vec<Element>, }
The root Document node.
Fields
class: DocumentClass
The document class.
preamble: Preamble
The Document
's preamble.
elements: Vec<Element>
The various elements inside this Document
.
Methods
impl Document
[src]
fn new(document_class: DocumentClass) -> Self
Create a new Document
with the specified DocumentClass
.
fn push<E>(&mut self, element: E) -> &mut Self where
E: Into<Element>,
E: Into<Element>,
Add an element to the Document
.
For convenience, Elements are automatically converted using into()
.
Methods from Deref<Target = Vec<Element>>
fn capacity(&self) -> usize
1.0.0
Returns the number of elements the vector can hold without reallocating.
Examples
let vec: Vec<i32> = Vec::with_capacity(10); assert_eq!(vec.capacity(), 10);
fn into_boxed_slice(self) -> Box<[T]>
1.0.0
Converts the vector into Box<[T]>
.
Note that this will drop any excess capacity. Calling this and
converting back to a vector with into_vec
is equivalent to calling
shrink_to_fit
.
Examples
let v = vec![1, 2, 3]; let slice = v.into_boxed_slice();
Any excess capacity is removed:
let mut vec = Vec::with_capacity(10); vec.extend([1, 2, 3].iter().cloned()); assert_eq!(vec.capacity(), 10); let slice = vec.into_boxed_slice(); assert_eq!(slice.into_vec().capacity(), 3);
fn as_slice(&self) -> &[T]
1.7.0
Extracts a slice containing the entire vector.
Equivalent to &s[..]
.
Examples
use std::io::{self, Write}; let buffer = vec![1, 2, 3, 5, 8]; io::sink().write(buffer.as_slice()).unwrap();
fn len(&self) -> usize
1.0.0
Returns the number of elements in the vector, also referred to as its 'length'.
Examples
let a = vec![1, 2, 3]; assert_eq!(a.len(), 3);
fn is_empty(&self) -> bool
1.0.0
Returns true
if the vector contains no elements.
Examples
let mut v = Vec::new(); assert!(v.is_empty()); v.push(1); assert!(!v.is_empty());
Trait Implementations
impl Clone for Document
[src]
fn clone(&self) -> Document
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Document
[src]
impl Default for Document
[src]
impl PartialEq for Document
[src]
fn eq(&self, __arg_0: &Document) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Document) -> bool
This method tests for !=
.
impl Deref for Document
[src]
type Target = Vec<Element>
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
A shortcut to let you iterate over the elements in the Document
.