Remove unnecessary raw stirngs.
This commit is contained in:
66
src/ast.rs
66
src/ast.rs
@@ -417,15 +417,15 @@ impl AST {
|
||||
///
|
||||
/// let engine = Engine::new();
|
||||
///
|
||||
/// let ast1 = engine.compile(r#"
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// "#)?;
|
||||
/// let ast1 = engine.compile("
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// ")?;
|
||||
///
|
||||
/// let ast2 = engine.compile(r#"
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
///
|
||||
/// let ast = ast1.merge(&ast2); // Merge 'ast2' into 'ast1'
|
||||
///
|
||||
@@ -469,15 +469,15 @@ impl AST {
|
||||
///
|
||||
/// let engine = Engine::new();
|
||||
///
|
||||
/// let mut ast1 = engine.compile(r#"
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// "#)?;
|
||||
/// let mut ast1 = engine.compile("
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// ")?;
|
||||
///
|
||||
/// let ast2 = engine.compile(r#"
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
///
|
||||
/// ast1.combine(ast2); // Combine 'ast2' into 'ast1'
|
||||
///
|
||||
@@ -523,16 +523,16 @@ impl AST {
|
||||
///
|
||||
/// let engine = Engine::new();
|
||||
///
|
||||
/// let ast1 = engine.compile(r#"
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// "#)?;
|
||||
/// let ast1 = engine.compile("
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// ")?;
|
||||
///
|
||||
/// let ast2 = engine.compile(r#"
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// fn error() { 0 }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// fn error() { 0 }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
///
|
||||
/// // Merge 'ast2', picking only 'error()' but not 'foo(_)', into 'ast1'
|
||||
/// let ast = ast1.merge_filtered(&ast2, |_, _, script, name, params|
|
||||
@@ -606,16 +606,16 @@ impl AST {
|
||||
///
|
||||
/// let engine = Engine::new();
|
||||
///
|
||||
/// let mut ast1 = engine.compile(r#"
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// "#)?;
|
||||
/// let mut ast1 = engine.compile("
|
||||
/// fn foo(x) { 42 + x }
|
||||
/// foo(1)
|
||||
/// ")?;
|
||||
///
|
||||
/// let ast2 = engine.compile(r#"
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// fn error() { 0 }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
/// fn foo(n) { `hello${n}` }
|
||||
/// fn error() { 0 }
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
///
|
||||
/// // Combine 'ast2', picking only 'error()' but not 'foo(_)', into 'ast1'
|
||||
/// ast1.combine_filtered(ast2, |_, _, script, name, params|
|
||||
@@ -664,9 +664,9 @@ impl AST {
|
||||
/// let engine = Engine::new();
|
||||
///
|
||||
/// let mut ast = engine.compile(r#"
|
||||
/// fn foo(n) { n + 1 }
|
||||
/// fn bar() { print("hello"); }
|
||||
/// "#)?;
|
||||
/// fn foo(n) { n + 1 }
|
||||
/// fn bar() { print("hello"); }
|
||||
/// "#)?;
|
||||
///
|
||||
/// // Remove all functions except 'foo(_)'
|
||||
/// ast.retain_functions(|_, _, name, params| name == "foo" && params == 1);
|
||||
|
@@ -1354,7 +1354,8 @@ impl Engine {
|
||||
///
|
||||
/// let map = engine.parse_json(
|
||||
/// r#"{"a":123, "b":42, "c":{"x":false, "y":true}, "d":null}"#
|
||||
/// .replace("{", "#{").as_str(), true)?;
|
||||
/// .replace("{", "#{").as_str(),
|
||||
/// true)?;
|
||||
///
|
||||
/// assert_eq!(map.len(), 4);
|
||||
/// assert_eq!(map["a"].as_int().unwrap(), 123);
|
||||
|
@@ -40,11 +40,12 @@ pub trait FuncArgs {
|
||||
/// let engine = Engine::new();
|
||||
/// let mut scope = Scope::new();
|
||||
///
|
||||
/// let ast = engine.compile(r#"
|
||||
/// fn hello(x, y, z) {
|
||||
/// if x { `hello ${y}` } else { y + z }
|
||||
/// }
|
||||
/// "#)?;
|
||||
/// let ast = engine.compile(
|
||||
/// "
|
||||
/// fn hello(x, y, z) {
|
||||
/// if x { `hello ${y}` } else { y + z }
|
||||
/// }
|
||||
/// ")?;
|
||||
///
|
||||
/// let result: String = engine.call_fn(&mut scope, &ast, "hello", options)?;
|
||||
///
|
||||
|
Reference in New Issue
Block a user