[][src]Struct spinoso_symbol::Inspect

#[must_use =
  "this `Inspect` is an `Iterator`, which should be consumed if constructed"]pub struct Inspect<'a>(_);
This is supported on crate feature inspect only.

An iterator that yields a debug representation of a Symbol and its byte contents as a sequence of chars.

This struct is created by the inspect method on Symbol. See its documentation for more.

To format a Symbol directly into a writer, see format_into or write_into.

Examples

To inspect an empty bytestring:

let inspect = Inspect::default();
let debug = inspect.collect::<String>();
assert_eq!(debug, r#":"""#);

To inspect a well-formed UTF-8 bytestring:

let inspect = Inspect::from("spinoso");
let debug = inspect.collect::<String>();
assert_eq!(debug, ":spinoso");

To inspect a bytestring with invalid UTF-8 bytes:

let inspect = Inspect::from(&b"invalid-\xFF-utf8"[..]);
let debug = inspect.collect::<String>();
assert_eq!(debug, r#":"invalid-\xFF-utf8""#);

Implementations

impl<'a> Inspect<'a>[src]

pub fn format_into<W>(self, mut dest: W) -> Result where
    W: Write
[src]

Write an Inspect iterator into the given destination using the debug representation of the interned byteslice associated with the symbol in the underlying interner.

This formatter writes content like :spinoso and :"invalid-\xFF-utf8". To see example output of the underlying iterator, see the Inspect documentation.

To write binary output, use write_into, which requires the std feature to be activated.

Errors

If the given writer returns an error as it is being written to, that error is returned.

Examples

let mut buf = String::new();
let iter = Inspect::from("spinoso");
iter.format_into(&mut buf);
assert_eq!(buf, ":spinoso");

let mut buf = String::new();
let iter = Inspect::from(&b"\xFF"[..]);
iter.format_into(&mut buf);
assert_eq!(buf, r#":"\xFF""#);

pub fn write_into<W>(self, mut dest: W) -> Result<()> where
    W: Write
[src]

This is supported on crate feature std only.

Write an Inspect iterator into the given destination using the debug representation of the interned byteslice associated with the symbol in the underlying interner.

This formatter writes content like :spinoso and :"invalid-\xFF-utf8". To see example output of the underlying iterator, see the Inspect documentation.

To write to a formatter, use format_into.

Errors

If the given writer returns an error as it is being written to, that error is returned.

Examples

let mut buf = Vec::new();
let iter = Inspect::from("spinoso");
iter.write_into(&mut buf);
assert_eq!(buf, &b":spinoso"[..]);

let mut buf = Vec::new();
let iter = Inspect::from(&b"\xFF"[..]);
iter.write_into(&mut buf);
assert_eq!(buf, &[b':', b'"', b'\\', b'x', b'F', b'F', b'"']);

Trait Implementations

impl<'a> Clone for Inspect<'a>[src]

impl<'a> Debug for Inspect<'a>[src]

impl<'a> Default for Inspect<'a>[src]

impl<'a> DoubleEndedIterator for Inspect<'a>[src]

impl<'a> From<&'a [u8]> for Inspect<'a>[src]

impl<'a> From<&'a str> for Inspect<'a>[src]

impl<'a> FusedIterator for Inspect<'a>[src]

impl<'a> Iterator for Inspect<'a>[src]

type Item = char

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Inspect<'a>[src]

impl<'a> Send for Inspect<'a>[src]

impl<'a> Sync for Inspect<'a>[src]

impl<'a> Unpin for Inspect<'a>[src]

impl<'a> UnwindSafe for Inspect<'a>[src]

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.