pub struct RuleItem<M, T> { /* private fields */ }
Expand description

Result of Ruler::add, allows to customize position of each rule.

Implementations

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");

Make sure this rule will be inserted after any rule defined by mark (if such rule exists). Similar to RuleItem::before.

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");

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.

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");

Require another rule identified by mark, panic if not found.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

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

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.