Struct parse_hyperlinks::iterator_html::Hyperlink[][src]

pub struct Hyperlink<'a> { /* fields omitted */ }

Iterator over the inline hyperlinks in the HTML formatted input text. This struct holds the iterator’s state as an advancing pointer into the input text. The iterator’s next() method returns a tuple with 2 tuples inside: Some(((input_split)(html_image_element))).

Each tuple has the following parts:

  • input_split = (skipped_characters, consumed_characters, remaining_characters)
  • html_hyperlink_elemet = (text_text, link_destination, link_title)

Input split

use parse_hyperlinks::iterator_html::Hyperlink;
use std::borrow::Cow;

let i = "abc<a href=\"dest1\" title=\"title1\">text1</a>abc\n\
         abc<a href=\"dest2\" title=\"title2\">text2</a>xyz";

let mut iter = Hyperlink::new(i);
assert_eq!(iter.next().unwrap().0,
           ("abc",
            "<a href=\"dest1\" title=\"title1\">text1</a>",
            "abc\nabc<a href=\"dest2\" title=\"title2\">text2</a>xyz")
          );
assert_eq!(iter.next().unwrap().0,
           ("abc\nabc",
            "<a href=\"dest2\" title=\"title2\">text2</a>",
            "xyz")
          );
assert_eq!(iter.next(), None);

Link content

HTML

use parse_hyperlinks::iterator_html::Hyperlink;
use std::borrow::Cow;

let i = "abc<a href=\"dest1\" title=\"title1\">text1</a>abc\
         abc<a href=\"dest2\" title=\"title2\">text2</a>abc";


let mut iter = Hyperlink::new(i);
assert_eq!(iter.next().unwrap().1, (Cow::from("text1"), Cow::from("dest1"), Cow::from("title1")));
assert_eq!(iter.next().unwrap().1, (Cow::from("text2"), Cow::from("dest2"), Cow::from("title2")));
assert_eq!(iter.next(), None);

Implementations

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

Constructor for the Hyperlink struct.

pub fn new(input: &'a str) -> Self[src]

Constructor for the iterator. input is the text with inline images to be extracted.

Trait Implementations

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

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

Iterator over the HTML inline images in the input-text. The iterator’s next() method returns a tuple with 2 tuples inside:

  • Some(((input_split)(link_content)))

Each tuple has the following parts:

  • input_split = (skipped_characters, consumed_characters, remaining_characters)
  • link_content = (link_text, link_destination, link_title)

type Item = ((&'a str, &'a str, &'a str), (Cow<'a, str>, Cow<'a, str>, Cow<'a, str>))

The type of the elements being iterated over.

impl<'a> PartialEq<Hyperlink<'a>> for Hyperlink<'a>[src]

impl<'a> StructuralPartialEq for Hyperlink<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Hyperlink<'a>

impl<'a> Send for Hyperlink<'a>

impl<'a> Sync for Hyperlink<'a>

impl<'a> Unpin for Hyperlink<'a>

impl<'a> UnwindSafe for Hyperlink<'a>

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> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

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.