Skip to content

Commit 479c61b

Browse files
committed
Fix returns(deref | as_ref | as_deref) in tracked methods
1 parent 13a2bd7 commit 479c61b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use salsa::Database;
2+
3+
#[salsa::input]
4+
struct Input {
5+
number: usize,
6+
}
7+
8+
#[salsa::tracked]
9+
impl Input {
10+
#[salsa::tracked(returns(deref))]
11+
fn test(self, db: &dyn salsa::Database) -> Vec<String> {
12+
(0..self.number(db)).map(|i| format!("test {i}")).collect()
13+
}
14+
}
15+
16+
#[test]
17+
fn invoke() {
18+
salsa::DatabaseImpl::new().attach(|db| {
19+
let input = Input::new(db, 3);
20+
let x: &[String] = input.test(db);
21+
22+
assert_eq!(
23+
x,
24+
&[
25+
"test 0".to_string(),
26+
"test 1".to_string(),
27+
"test 2".to_string()
28+
]
29+
);
30+
})
31+
}

0 commit comments

Comments
 (0)