Debian Codegraph @

gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/datafrog/README.md

raw
1 # datafrog
2
3 Datafrog is a lightweight Datalog engine intended to be embedded in other Rust programs.
4
5 Datafrog has no runtime, and relies on you to build and repeatedly apply the update rules.
6 It tries to help you do this correctly. As an example, here is how you might write a reachability
7 query using Datafrog (minus the part where we populate the `nodes` and `edges` initial relations).
8
9 ```rust
10 extern crate datafrog;
11 use datafrog::Iteration;
12
13 fn main() {
14
15 // Create a new iteration context, ...
16 let mut iteration = Iteration::new();
17
18 // .. some variables, ..
19 let nodes_var = iteration.variable::<(u32,u32)>("nodes");
20 let edges_var = iteration.variable::<(u32,u32)>("edges");
21
22 // .. load them with some initial values, ..
23 nodes_var.insert(nodes.into());
24 edges_var.insert(edges.into());
25
26 // .. and then start iterating rules!
27 while iteration.changed() {
28 // nodes(a,c) <- nodes(a,b), edges(b,c)
29 nodes_var.from_join(&nodes_var, &edges_var, |_b, &a, &c| (c,a));
30 }
31
32 // extract the final results.
33 let reachable: Vec<(u32,u32)> = variable.complete();
34 }
35 ```
36
37 If you'd like to read more about how it works, check out [this blog post](https://github.com/frankmcsherry/blog/blob/master/posts/2018-05-19.md).
38
39 ## Authorship
40
41 Datafrog was initially developed by [Frank McSherry][fmc] and was
42 later transferred to the rust-lang-nursery organization. Thanks Frank!
43
44 [fmc]: https://github.com/frankmcsherry