[][src]Struct quoted_string::ContentChars

pub struct ContentChars<'a, Impl: GeneralQSSpec> { /* fields omitted */ }

A iterator over chars of the content represented by the quoted strings (PartialEq<&str>)

It will on the fly (without extra allocation) remove the surrounding quotes and unquote quoted-pairs

It implements Eq, and PartialEq with str, &str and itself. This enables to compare a quoted string with a string representing the content of a quoted string.

While it does not explicity checks for validity of the quoted-string it iterates over it still might notice that it is invalid as such it returns results (i.e. let the consumer decide how to handle the error). If you are fine with a panic if the ContentChars iterator was created from a invalid quoted-string, then just use .map(|r| r.expect("[BUG] ContentChars was created from malformed quoted-string"). (Note that the the only 2two thinks the current implementation does not check are if a char in a quoted-pair is valid (= is quotable) and it does not call end_validation on the internally used QuotedValidator, but thats a implementation detail for now)

Example

// use your own Spec instead
use quoted_string::test_utils::TestSpec;
use quoted_string::ContentChars;
use quoted_string::AsciiCaseInsensitiveEq;

let quoted_string = r#""ab\"\ c""#;
let cc = ContentChars::<TestSpec>::from_str(quoted_string);
assert_eq!(cc, "ab\" c");
assert!(cc.eq_ignore_ascii_case("AB\" c"));
assert_eq!(cc.collect::<Result<Vec<_>,_>>().unwrap().as_slice(), &[ 'a', 'b', '"', ' ', 'c' ] );

Methods

impl<'s, Impl> ContentChars<'s, Impl> where
    Impl: GeneralQSSpec
[src]

pub fn from_str(quoted: &'s str) -> Self[src]

creates a char iterator over the content of a quoted string

the quoted string is assumed to be valid and not explicitely checked for validity but because of the way unquoting works a number of error can be detected

pub fn from_parts_unchecked(
    partial_quoted_content: &'s str,
    automaton: ScanAutomaton<Impl::Parsing>
) -> Self
[src]

creates a ContentChars iterator from a str and a QuotedValidator

The partial_quoted_content is assumed to be a valid quoted string without the surrounding '"'. It might not be a the complete content of a quoted string but if it isn't the q_validator is expected to have been used on a chars stripped on the left side (and no more than that). Note that it can work with using it on less then all chars but this depends on the Spec used. E.g. if any decison of the spec only depends on the current char (QuotedValidator is zero-sized) then no char had to be used with it.

Trait Implementations

impl<'a, Spec> AsciiCaseInsensitiveEq<str> for ContentChars<'a, Spec> where
    Spec: GeneralQSSpec
[src]

impl<'a, 'b, Spec> AsciiCaseInsensitiveEq<ContentChars<'b, Spec>> for ContentChars<'a, Spec> where
    Spec: GeneralQSSpec
[src]

impl<'a, 'b, Spec> AsciiCaseInsensitiveEq<ContentChars<'b, Spec>> for &'a str where
    Spec: GeneralQSSpec
[src]

impl<'a, 'b, Spec> AsciiCaseInsensitiveEq<&'b str> for ContentChars<'a, Spec> where
    Spec: GeneralQSSpec
[src]

impl<'a, Impl> Iterator for ContentChars<'a, Impl> where
    Impl: GeneralQSSpec
[src]

type Item = Result<char, CoreError>

The type of the elements being iterated over.

impl<'a, Impl: Clone + GeneralQSSpec> Clone for ContentChars<'a, Impl> where
    Impl::Parsing: Clone
[src]

impl<'a, Spec> PartialEq<str> for ContentChars<'a, Spec> where
    Spec: GeneralQSSpec
[src]

impl<'a, 'b, Spec> PartialEq<ContentChars<'b, Spec>> for &'a str where
    Spec: GeneralQSSpec
[src]

impl<'a, 'b, Spec> PartialEq<&'b str> for ContentChars<'a, Spec> where
    Spec: GeneralQSSpec
[src]

impl<'a, 'b, Spec> PartialEq<ContentChars<'b, Spec>> for ContentChars<'a, Spec> where
    Spec: GeneralQSSpec
[src]

impl<'a, Impl: Debug + GeneralQSSpec> Debug for ContentChars<'a, Impl> where
    Impl::Parsing: Debug
[src]

Auto Trait Implementations

impl<'a, Impl> Send for ContentChars<'a, Impl> where
    <Impl as GeneralQSSpec>::Parsing: Send

impl<'a, Impl> Sync for ContentChars<'a, Impl> where
    <Impl as GeneralQSSpec>::Parsing: Sync

impl<'a, Impl> Unpin for ContentChars<'a, Impl> where
    <Impl as GeneralQSSpec>::Parsing: Unpin

impl<'a, Impl> UnwindSafe for ContentChars<'a, Impl> where
    <Impl as GeneralQSSpec>::Parsing: UnwindSafe

impl<'a, Impl> RefUnwindSafe for ContentChars<'a, Impl> where
    <Impl as GeneralQSSpec>::Parsing: RefUnwindSafe

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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