Crate hashtag

Source
Expand description

The goal of this crate is to match Instagram’s parsing of hashtags. So if you find strings that aren’t parsed correctly please open an issue 😃

§Example

use hashtag::{Hashtag, HashtagParser};
use std::borrow::Cow;

let mut parser = HashtagParser::new("#rust is #awesome");

assert_eq!(
    parser.next().unwrap(),
    Hashtag {
        text: Cow::from("rust"),
        start: 0,
        end: 4,
    }
);

assert_eq!(
    parser.next().unwrap(),
    Hashtag {
        text: Cow::from("awesome"),
        start: 9,
        end: 16,
    }
);

assert_eq!(parser.next(), None);

See tests for specifics about what is considered a hashtag and what is not.

§Features

  • serde: Enable #[derive(Serialize)] for Hashtag.

Structs§

  • A hashtag found in some text. See documentation of top level module for more info.
  • A parser that finds hashtags in a string.