[−][src]Struct tokenizers::Token
Encapsulates the string term of a token.
The term that the token encapsulates is wrapped in a Cow
(copy-on-write),
so that the string slice is only copied if it is modified.
Fields
offset: Option<usize>
The index of the token within the original un-tokenized string slice.
Methods
impl<'a> Token<'a>
[src]
pub fn new(term: &'a str, offset: Option<usize>) -> Self
[src]
Create a new Token
object.
pub fn from(term: &'a str) -> Self
[src]
Initializes a Token
from a string slice.
pub fn as_str(&self) -> &str
[src]
Extracts the string slice contained in the Token
.
Examples
let s = "Hello"; let token = tokenizers::Token::from(s); assert_eq!(token.as_str(), s);
pub fn as_mut_str(&mut self) -> &mut str
[src]
Returns a mutable reference to the contained string slice.
Examples
let mut token = tokenizers::Token::from("Hello"); token.as_mut_str().make_ascii_lowercase(); assert_eq!(token.as_str(), "hello");
pub fn into_string(self) -> String
[src]
Clones the contained string slice if it is not already owned (i.e. if it has not already
been modified) and returns it as a String
.
Examples
let mut token = tokenizers::Token::from("Hello"); assert_eq!(token.into_string(), String::from("Hello"));
Trait Implementations
impl<'a> Eq for Token<'a>
[src]
impl<'a> PartialEq<Token<'a>> for Token<'a>
[src]
impl<'a> PartialEq<String> for Token<'a>
[src]
impl<'a, '_> PartialEq<&'_ str> for Token<'a>
[src]
impl<'a> Display for Token<'a>
[src]
Auto Trait Implementations
impl<'a> Send for Token<'a>
impl<'a> Sync for Token<'a>
impl<'a> Unpin for Token<'a>
impl<'a> UnwindSafe for Token<'a>
impl<'a> RefUnwindSafe for Token<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> 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, U> TryInto<U> 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> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,