Struct str_stack::StrStack [] [src]

pub struct StrStack { /* fields omitted */ }

Methods

impl StrStack
[src]

Create a new StrStack.

Create a new StrStack with the given capacity.

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

Push a string onto the string stack.

This returns the index of the string on the stack.

Iterate over the strings on the stack.

Remove the top string from the stack.

Returns true iff a string was removed.

Clear the stack.

Returns the number of strings on the stack.

Truncate the stack to len strings.

Read from source into the string stack.

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

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!");

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!");

Trait Implementations

impl Clone for StrStack
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for StrStack
[src]

Returns the "default value" for a type. Read more

impl Index<usize> for StrStack
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl Debug for StrStack
[src]

Formats the value using the given formatter.

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

Which kind of iterator are we turning this into?

The type of the elements being iterated over.

Creates an iterator from a value. Read more

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

Extends a collection with the contents of an iterator. Read more

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

Creates a value from an iterator. Read more