pub struct Formatting(/* private fields */);
Expand description
The default formatting used for rendering some text.
Implementations§
Source§impl Formatting
impl Formatting
Sourcepub const UNDERSCORE: Self
pub const UNDERSCORE: Self
Represents underscore formatting.
Sourcepub const STRIKETHROUGH: Self
pub const STRIKETHROUGH: Self
Represents strikethrough formatting.
Sourcepub fn contains(self, formatting: Self) -> bool
pub fn contains(self, formatting: Self) -> bool
Checks if the Formatting
instance contains any of the specified formatting flags.
§Examples
Check if a Formatting
instance contains specific formatting flags:
use pukram_formatting::Formatting;
let formatting = Formatting::BOLD | Formatting::ITALIC;
assert!(formatting.contains(Formatting::BOLD));
assert!(formatting.contains(Formatting::ITALIC));
assert!(!formatting.contains(Formatting::MONO));
Sourcepub fn is_empty(self) -> bool
pub fn is_empty(self) -> bool
Checks if the Formatting
instance has no formatting flags set.
§Examples
Check if a Formatting
instance is empty:
use pukram_formatting::Formatting;
let formatting = Formatting::default();
assert!(formatting.is_empty());
let formatting = Formatting::BOLD | Formatting::ITALIC;
assert!(!formatting.is_empty());
Sourcepub fn is_underscore(self) -> bool
pub fn is_underscore(self) -> bool
Checks if underscore formatting is activated.
Sourcepub fn is_strikethrough(self) -> bool
pub fn is_strikethrough(self) -> bool
Checks if strikethrough formatting is activated.
Source§impl Formatting
impl Formatting
Sourcepub fn apply(&mut self, c: char) -> bool
pub fn apply(&mut self, c: char) -> bool
Apply character specific formatting and return if it has been changed.
§Examples
Apply formatting characters to a Formatting
instance:
use pukram_formatting::Formatting;
let mut formatting = Formatting::default();
assert!(formatting.is_empty());
assert!(formatting.apply('*'));
assert!(formatting.is_bold());
assert!(formatting.apply('/'));
assert!(formatting.is_italic());
assert!(!formatting.apply('A'));
assert!(formatting.apply('*'));
assert!(!formatting.is_bold());
Trait Implementations§
Source§impl BitAnd for Formatting
impl BitAnd for Formatting
Source§type Output = Formatting
type Output = Formatting
The resulting type after applying the
&
operator.Source§fn bitand(self, rhs: Formatting) -> Formatting
fn bitand(self, rhs: Formatting) -> Formatting
Performs the
&
operation. Read moreSource§impl BitAndAssign for Formatting
impl BitAndAssign for Formatting
Source§fn bitand_assign(&mut self, rhs: Formatting)
fn bitand_assign(&mut self, rhs: Formatting)
Performs the
&=
operation. Read moreSource§impl BitOr for Formatting
impl BitOr for Formatting
Source§type Output = Formatting
type Output = Formatting
The resulting type after applying the
|
operator.Source§fn bitor(self, rhs: Formatting) -> Formatting
fn bitor(self, rhs: Formatting) -> Formatting
Performs the
|
operation. Read moreSource§impl BitOrAssign for Formatting
impl BitOrAssign for Formatting
Source§fn bitor_assign(&mut self, rhs: Formatting)
fn bitor_assign(&mut self, rhs: Formatting)
Performs the
|=
operation. Read moreSource§impl BitXor for Formatting
impl BitXor for Formatting
Source§type Output = Formatting
type Output = Formatting
The resulting type after applying the
^
operator.Source§fn bitxor(self, rhs: Formatting) -> Formatting
fn bitxor(self, rhs: Formatting) -> Formatting
Performs the
^
operation. Read moreSource§impl BitXorAssign for Formatting
impl BitXorAssign for Formatting
Source§fn bitxor_assign(&mut self, rhs: Formatting)
fn bitxor_assign(&mut self, rhs: Formatting)
Performs the
^=
operation. Read moreSource§impl Clone for Formatting
impl Clone for Formatting
Source§fn clone(&self) -> Formatting
fn clone(&self) -> Formatting
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for Formatting
impl Default for Formatting
Source§fn default() -> Formatting
fn default() -> Formatting
Returns the “default value” for a type. Read more
impl Copy for Formatting
Auto Trait Implementations§
impl Freeze for Formatting
impl RefUnwindSafe for Formatting
impl Send for Formatting
impl Sync for Formatting
impl Unpin for Formatting
impl UnwindSafe for Formatting
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