mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-28 15:26:34 +00:00
commit
bfcca3059c
2 changed files with 10 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "salsa"
|
name = "salsa"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
authors = ["Niko Matsakis <niko@alum.mit.edu>"]
|
authors = ["Niko Matsakis <niko@alum.mit.edu>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "Apache-2.0 OR MIT"
|
license = "Apache-2.0 OR MIT"
|
||||||
|
|
|
@ -163,11 +163,11 @@ start using it:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
let db = DatabaseStruct::default();
|
let mut db = DatabaseStruct::default();
|
||||||
|
|
||||||
println!("Initially, the length is {}.", db.length().get(()));
|
println!("Initially, the length is {}.", db.length().get(()));
|
||||||
|
|
||||||
db.query(InputString)
|
db.query_mut(InputString)
|
||||||
.set((), Arc::new(format!("Hello, world")));
|
.set((), Arc::new(format!("Hello, world")));
|
||||||
|
|
||||||
println!("Now, the length is {}.", db.length().get(()));
|
println!("Now, the length is {}.", db.length().get(()));
|
||||||
|
@ -177,16 +177,16 @@ fn main() {
|
||||||
One thing to notice here is how we set the value for an input query:
|
One thing to notice here is how we set the value for an input query:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
db.query(InputString)
|
db.query_mut(InputString)
|
||||||
.set((), Arc::new(format!("Hello, world")));
|
.set((), Arc::new(format!("Hello, world")));
|
||||||
```
|
```
|
||||||
|
|
||||||
The `db.query(Foo)` method takes as argument the query type that
|
The `db.query_mut(Foo)` method takes as argument the query type that
|
||||||
characterizes your query. It gives back a "query table" type, which
|
characterizes your query. It gives back a "mutable query table" type,
|
||||||
offers you more advanced methods beyond simply executing the query
|
which lets you invoke `set` to set the value of an input query. There
|
||||||
(for example, for input queries, you can invoke `set`). In fact, the
|
is also a `query` method that gives access to other advanced methods
|
||||||
standard call `db.query_name(key)` to access a query is just a
|
in fact, the standard call `db.query_name(key)` to access a query is
|
||||||
shorthand for `db.query(QueryType).get(key)`.
|
just a shorthand for `db.query(QueryType).get(key)`.
|
||||||
|
|
||||||
Finally, if we run this code:
|
Finally, if we run this code:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue