pub struct RuleItem<M, T> { /* private fields */ }Expand description
Result of Ruler::add, allows to customize position of each rule.
Implementations
sourceimpl<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 rule exists).
use markdown_it::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 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_it::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 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_it::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> RefUnwindSafe for RuleItem<M, T> where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<M, T> Send for RuleItem<M, T> where
M: Send,
T: Send,
impl<M, T> Sync for RuleItem<M, T> where
M: Sync,
T: Sync,
impl<M, T> Unpin for RuleItem<M, T> where
M: Unpin,
T: Unpin,
impl<M, T> UnwindSafe for RuleItem<M, T> where
M: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more