Struct hashtag::Hashtag [] [src]

pub struct Hashtag {
    pub text: String,
    pub start: usize,
    pub end: usize,
}

A hashtag found in some text. See documentation of top level module for more info.

Fields

The text of the hashtag. If hashtag is "#rust" the text will be "rust".

assert_eq!(
    Hashtag::parse("#rust").get(0).unwrap().text,
    "rust".to_string()
);

The starting index of the hashtag. This includes the # character. This makes it easier to highlight the hashtags later. If the full text we're parsing is "#rust" then start will be 0.

assert_eq!(
    Hashtag::parse("#rust").get(0).unwrap().start,
    0
);

The ending index of the hashtag, inclusive. If the full text we're parsing is "#rust" then end will be 4.

assert_eq!(
    Hashtag::parse("#rust").get(0).unwrap().end,
    4
);

Methods

impl Hashtag
[src]

[src]

Parse a string and return a vector of the hashtags.

[src]

Convert a Hashtag into JSON using serde_json.

At Tonsser we use this crate from our Rails API with helix and because helix only supports passing strings back and forth we serialize the data as JSON and deserialize it in Ruby land.

Trait Implementations

impl Eq for Hashtag
[src]

impl PartialEq for Hashtag
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Debug for Hashtag
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Hashtag

impl Sync for Hashtag