pub struct TxtProcessor { /* private fields */ }Expand description
TxtProcessor struct
Implementations§
Source§impl TxtProcessor
impl TxtProcessor
Sourcepub fn count_word_occurences(&self, word: &str) -> usize
pub fn count_word_occurences(&self, word: &str) -> usize
Reads text from file
Sourcepub fn find_unique(&self) -> Vec<String>
pub fn find_unique(&self) -> Vec<String>
Finds unique words in a text
Sourcepub fn filter(&self, condition: &dyn Fn(&str) -> bool) -> Vec<String>
pub fn filter(&self, condition: &dyn Fn(&str) -> bool) -> Vec<String>
Finds all words matching the condition
Sourcepub fn find_first_occurence(&self, word: &str) -> Result<usize, Error>
pub fn find_first_occurence(&self, word: &str) -> Result<usize, Error>
Finds the first ocuurence of a word in a text
Sourcepub fn search_occurences(&self, word: &str) -> Vec<usize>
pub fn search_occurences(&self, word: &str) -> Vec<usize>
Finds all occurrences of a word in a text
Sourcepub fn search_with_index(&self, index: usize) -> Result<String, Error>
pub fn search_with_index(&self, index: usize) -> Result<String, Error>
Finds word on that position in a text
Sourcepub fn replace_word(&mut self, from: &str, to: &str)
pub fn replace_word(&mut self, from: &str, to: &str)
Replaces all words ‘from’ on word ‘to’
Sourcepub fn replace_char(&mut self, from: char, to: char)
pub fn replace_char(&mut self, from: char, to: char)
Replaces all characters ‘from’ on character ‘to’
Sourcepub fn rewrite_file(&self, file_path: &str) -> Result<(), Error>
pub fn rewrite_file(&self, file_path: &str) -> Result<(), Error>
Rewrites file with self.content
Sourcepub fn search_with_regex(&self, regex: Regex) -> Vec<String>
pub fn search_with_regex(&self, regex: Regex) -> Vec<String>
Search for all words matching this regular expression
Sourcepub fn add_to_content(&mut self, text: String)
pub fn add_to_content(&mut self, text: String)
Adds text to this TxtProcessor’s content
Sourcepub fn get_content(&self) -> String
pub fn get_content(&self) -> String
Returns content
Sourcepub fn get_file_path(&self) -> Option<String>
pub fn get_file_path(&self) -> Option<String>
Returns file path
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TxtProcessor
impl RefUnwindSafe for TxtProcessor
impl Send for TxtProcessor
impl Sync for TxtProcessor
impl Unpin for TxtProcessor
impl UnwindSafe for TxtProcessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more