pub struct BioReader { /* private fields */ }Expand description
A BioReader object, allowing for customizing the bio-reading experience.
Implementations§
Source§impl BioReader
impl BioReader
Sourcepub fn emphasize(self, f: fn(_: &str) -> String) -> Self
pub fn emphasize(self, f: fn(_: &str) -> String) -> Self
Set the function to emphasize part of a word. Default to bold if environment supports it.
§Example
use bio_read::BioReader;
let reader = BioReader::new().emphasize(|s| format!("**{s}**")); // Emphasize by wrapping with `**`
assert_eq!(reader.bio_read_text("hello world"), "**hel**lo **wor**ld");§See also
Other methods that can be used to customize the BioReader:
Sourcepub fn de_emphasize(self, f: fn(_: &str) -> String) -> Self
pub fn de_emphasize(self, f: fn(_: &str) -> String) -> Self
Set the function to de-emphasize part of a word. Default to dimmed if environment supports it.
§Example
use bio_read::BioReader;
let reader = BioReader::new().de_emphasize(|s| format!("_{s}_")); // De-emphasize by wrapping with `_`
assert_eq!(reader.bio_read_text("hello world"), "hel_lo_ wor_ld_");§See also
Other methods that can be used to customize the BioReader:
Sourcepub fn fixation_point(self, fixation_point: usize) -> Self
pub fn fixation_point(self, fixation_point: usize) -> Self
Set the fixation point. The lower the fixation point, the more characters will be emphasized. The fixation_point should be in range [1, 5], defaulting to 3 when not specified.
§Example
use bio_read::BioReader;
let reader = BioReader::new()
.emphasize(|s| format!("**{s}**"))
.fixation_point(1); // Set fixation point to 1
assert_eq!(reader.bio_read_word("pneumonoultramicroscopicsilicovolcanoconiosis"), "**pneumonoultramicroscopicsilicovolcano**coniosis");
let reader = BioReader::new()
.emphasize(|s| format!("**{s}**"))
.fixation_point(5); // Set fixation point to 5
assert_eq!(reader.bio_read_word("pneumonoultramicroscopicsilicovolcanoconiosis"), "**pneumonoult**ramicroscopicsilicovolcanoconiosis");§Panics
Panics if fixation_point is not in range [1, 5].
§See also
Other methods that can be used to customize the BioReader:
Sourcepub fn bio_read_word(&self, word: &str) -> String
pub fn bio_read_word(&self, word: &str) -> String
Sourcepub fn bio_read_text(&self, text: &str) -> String
pub fn bio_read_text(&self, text: &str) -> String
Auto Trait Implementations§
impl Freeze for BioReader
impl RefUnwindSafe for BioReader
impl Send for BioReader
impl Sync for BioReader
impl Unpin for BioReader
impl UnwindSafe for BioReader
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