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
text: String
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() );
start: usize
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 );
end: usize
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]
pub fn parse(text: &str) -> Vec<Self>
[src]
Parse a string and return a vector of the hashtags.
pub fn to_json(&self) -> String
[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]
fn eq(&self, __arg_0: &Hashtag) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Hashtag) -> bool
[src]
This method tests for !=
.