Struct str_stack::StrStack[][src]

pub struct StrStack { /* fields omitted */ }

Implementations

impl StrStack[src]

pub fn new() -> StrStack[src]

Create a new StrStack.

pub fn with_capacity(bytes: usize, strings: usize) -> StrStack[src]

Create a new StrStack with the given capacity.

You will be able to push bytes bytes and create strings strings before reallocating.

pub fn push(&mut self, s: &str) -> usize[src]

Push a string onto the string stack.

This returns the index of the string on the stack.

pub fn iter(&self) -> Iter<'_>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = &'a str;
[src]

Iterate over the strings on the stack.

pub fn pop(&mut self) -> bool[src]

Remove the top string from the stack.

Returns true iff a string was removed.

pub fn clear(&mut self)[src]

Clear the stack.

pub fn len(&self) -> usize[src]

Returns the number of strings on the stack.

pub fn truncate(&mut self, len: usize)[src]

Truncate the stack to len strings.

pub fn consume<R: Read>(&mut self, source: R) -> Result<usize>[src]

Read from source into the string stack.

Returns the index of the new string or an IO Error.

pub fn writer(&mut self) -> Writer<'_>[src]

Returns a writer helper for this string stack.

This is useful for building a string in-place on the string-stack.

Example:

use std::fmt::Write;
use str_stack::StrStack;

let mut s = StrStack::new();
let index = {
    let mut writer = s.writer();
    writer.write_str("Hello");
    writer.write_char(' ');
    writer.write_str("World");
    writer.write_char('!');
    writer.finish()
};
assert_eq!(&s[index], "Hello World!");

pub fn write_fmt(&mut self, args: Arguments<'_>) -> usize[src]

Allows calling the write! macro directly on the string stack:

Example:

use std::fmt::Write;
use str_stack::StrStack;

let mut s = StrStack::new();
let index = write!(&mut s, "Hello {}!", "World");
assert_eq!(&s[index], "Hello World!");

pub unsafe fn get_unchecked(&self, index: usize) -> &str[src]

Trait Implementations

impl Clone for StrStack[src]

impl Debug for StrStack[src]

impl Default for StrStack[src]

impl<S> Extend<S> for StrStack where
    S: AsRef<str>, 
[src]

impl<S> FromIterator<S> for StrStack where
    S: AsRef<str>, 
[src]

impl Index<usize> for StrStack[src]

type Output = str

The returned type after indexing.

impl<'a> IntoIterator for &'a StrStack[src]

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

type Item = &'a str

The type of the elements being iterated over.

Auto Trait Implementations

impl RefUnwindSafe for StrStack

impl Send for StrStack

impl Sync for StrStack

impl Unpin for StrStack

impl UnwindSafe for StrStack

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.