[−][src]Struct hashtag::Hashtag
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 PartialEq<Hashtag> for Hashtag
[src]
impl Eq for Hashtag
[src]
impl Debug for Hashtag
[src]
impl Serialize for Hashtag
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for Hashtag
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,