2019-03-27 09:35:09 +00:00
|
|
|
extern crate salsa;
|
|
|
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
2019-03-27 09:44:48 +00:00
|
|
|
#[salsa::query_group(NoSendSyncStorage)]
|
|
|
|
trait NoSendSyncDatabase: salsa::Database {
|
|
|
|
fn no_send_sync_value(&self, key: bool) -> Rc<bool>;
|
|
|
|
fn no_send_sync_key(&self, key: Rc<bool>) -> bool;
|
|
|
|
}
|
2019-03-27 09:35:09 +00:00
|
|
|
|
2019-04-03 14:01:38 +00:00
|
|
|
fn no_send_sync_value(_db: &impl NoSendSyncDatabase, key: bool) -> Rc<bool> {
|
2019-03-27 09:44:48 +00:00
|
|
|
Rc::new(key)
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|
|
|
|
|
2019-04-03 14:01:38 +00:00
|
|
|
fn no_send_sync_key(_db: &impl NoSendSyncDatabase, key: Rc<bool>) -> bool {
|
2019-03-27 09:44:48 +00:00
|
|
|
*key
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|
|
|
|
|
2019-03-27 09:44:48 +00:00
|
|
|
#[salsa::database(NoSendSyncStorage)]
|
2019-03-27 09:35:09 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
struct DatabaseImpl {
|
|
|
|
runtime: salsa::Runtime<DatabaseImpl>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl salsa::Database for DatabaseImpl {
|
|
|
|
fn salsa_runtime(&self) -> &salsa::Runtime<DatabaseImpl> {
|
|
|
|
&self.runtime
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_send_sync() {
|
2019-04-03 14:01:38 +00:00
|
|
|
let db = DatabaseImpl::default();
|
2019-03-27 09:35:09 +00:00
|
|
|
|
2019-03-27 09:44:48 +00:00
|
|
|
assert_eq!(db.no_send_sync_value(true), Rc::new(true));
|
|
|
|
assert_eq!(db.no_send_sync_key(Rc::new(false)), false);
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|