[][src]Macro gitrevset::ast

macro_rules! ast {
    ($v:literal) => { ... };
    ($fname:ident ( $($arg:tt $( ( $($subargs:tt)* ) )? ),* )) => { ... };
    {$v:expr} => { ... };
}

Construct an AST statically. This can be useful to avoid escaping issues parsing strings.

Example

let expr = ast!(union(draft(), desc("foo")));
assert_eq!(expr.to_string(), "union(draft(), desc(foo))");

Use { ... } to refer to local variables:

let name = "origin/master";
let expr = ast!(ref({ name }));
assert_eq!(expr.to_string(), "ref(origin/master)");
let nested = ast!(parents({ expr }));
assert_eq!(nested.to_string(), "parents(ref(origin/master))");

Set can also be referred:

let head = repo.revs(ast!(head()))?;
let set = repo.revs(ast!(parents({ head })))?;

// The above is similar to using raw `dag` APIs:
let set2 = {
    let dag = repo.dag();
    dag.parents(dag.heads(dag.all()?)?)?
};