pub struct RuleItem<M, T> { /* private fields */ }
Expand description
Result of Ruler::add, allows customizing the position of each rule.
Implementations§
Source§impl<M: Copy, T> RuleItem<M, T>
impl<M: Copy, T> RuleItem<M, T>
Sourcepub fn before(&mut self, mark: M) -> &mut Self
pub fn before(&mut self, mark: M) -> &mut Self
Make sure this rule will be inserted before any rule defined by mark
(if such a rule exists).
use markdown_that::common::ruler::Ruler;
let mut chain = Ruler::<&str, fn (&mut String)>::new();
chain.add("a", |s| s.push_str("bar"));
chain.add("b", |s| s.push_str("foo")).before("a");
let mut result = String::new();
for f in chain.iter() { f(&mut result); }
assert_eq!(result, "foobar");
Sourcepub fn after(&mut self, mark: M) -> &mut Self
pub fn after(&mut self, mark: M) -> &mut Self
Make sure this rule will be inserted after any rule defined by mark
(if such a rule exists).
Similar to RuleItem::before.
Sourcepub fn before_all(&mut self) -> &mut Self
pub fn before_all(&mut self) -> &mut Self
This rule will be inserted as early as possible, while still taking into account dependencies,
i.e. .after(X).before_all()
causes this to be first rule after X.
use markdown_that::common::ruler::Ruler;
let mut chain = Ruler::<&str, fn (&mut String)>::new();
chain.add("a", |s| s.push_str("A"));
chain.add("c", |s| s.push_str("C")).after("a");
chain.add("b", |s| s.push_str("B")).after("a").before_all();
let mut result = String::new();
for f in chain.iter() { f(&mut result); }
// without before_all order will be ACB
assert_eq!(result, "ABC");
Sourcepub fn after_all(&mut self) -> &mut Self
pub fn after_all(&mut self) -> &mut Self
This rule will be inserted as late as possible, while still taking into account dependencies,
i.e. .before(X).after_all()
causes this to be the last rule before X.
Similar to RuleItem::before_all.
Sourcepub fn alias(&mut self, mark: M) -> &mut Self
pub fn alias(&mut self, mark: M) -> &mut Self
Add another auxiliary identifier to this rule. It can be used to group together multiple rules with similar functionality.
use markdown_that::common::ruler::Ruler;
let mut chain = Ruler::<&str, fn (&mut String)>::new();
chain.add("b", |s| s.push_str("B")).alias("BorC");
chain.add("c", |s| s.push_str("C")).alias("BorC");
chain.add("a", |s| s.push_str("A")).before("BorC");
let mut result = String::new();
for f in chain.iter() { f(&mut result); }
assert_eq!(result, "ABC");
Trait Implementations§
Auto Trait Implementations§
impl<M, T> Freeze for RuleItem<M, T>where
T: Freeze,
impl<M, T> RefUnwindSafe for RuleItem<M, T>where
T: RefUnwindSafe,
M: RefUnwindSafe,
impl<M, T> Send for RuleItem<M, T>
impl<M, T> Sync for RuleItem<M, T>
impl<M, T> Unpin for RuleItem<M, T>
impl<M, T> UnwindSafe for RuleItem<M, T>where
T: UnwindSafe,
M: UnwindSafe,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.