mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
Added test case for !Send + !Sync
keys (vs. values)
This commit is contained in:
parent
0696ed8c3b
commit
065d691175
1 changed files with 13 additions and 10 deletions
|
@ -3,19 +3,21 @@ extern crate salsa;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
// #[derive(Clone, PartialEq, Eq, Debug)]
|
#[salsa::query_group(NoSendSyncStorage)]
|
||||||
// struct Dummy;
|
trait NoSendSyncDatabase: salsa::Database {
|
||||||
|
fn no_send_sync_value(&self, key: bool) -> Rc<bool>;
|
||||||
#[salsa::query_group(NoSendStorage)]
|
fn no_send_sync_key(&self, key: Rc<bool>) -> bool;
|
||||||
trait NoSendDatabase: salsa::Database {
|
|
||||||
fn query(&self, key: ()) -> Rc<bool>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query(db: &impl NoSendDatabase, (): ()) -> Rc<bool> {
|
fn no_send_sync_value(db: &impl NoSendSyncDatabase, key: bool) -> Rc<bool> {
|
||||||
Rc::new(true)
|
Rc::new(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::database(NoSendStorage)]
|
fn no_send_sync_key(db: &impl NoSendSyncDatabase, key: Rc<bool>) -> bool {
|
||||||
|
*key
|
||||||
|
}
|
||||||
|
|
||||||
|
#[salsa::database(NoSendSyncStorage)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct DatabaseImpl {
|
struct DatabaseImpl {
|
||||||
runtime: salsa::Runtime<DatabaseImpl>,
|
runtime: salsa::Runtime<DatabaseImpl>,
|
||||||
|
@ -31,5 +33,6 @@ impl salsa::Database for DatabaseImpl {
|
||||||
fn no_send_sync() {
|
fn no_send_sync() {
|
||||||
let mut db = DatabaseImpl::default();
|
let mut db = DatabaseImpl::default();
|
||||||
|
|
||||||
db.query(());
|
assert_eq!(db.no_send_sync_value(true), Rc::new(true));
|
||||||
|
assert_eq!(db.no_send_sync_key(Rc::new(false)), false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue