mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 20:20:26 +00:00
25 lines
563 B
Rust
25 lines
563 B
Rust
//! Compile Singleton struct test:
|
|
//!
|
|
//! Singleton flags are only allowed for input structs. If applied on any other Salsa struct compilation must fail
|
|
|
|
#[salsa::input(singleton)]
|
|
struct MyInput {
|
|
field: u32,
|
|
}
|
|
|
|
#[salsa::tracked(singleton)]
|
|
struct MyTracked<'db> {
|
|
field: u32,
|
|
}
|
|
|
|
#[salsa::tracked(singleton)]
|
|
fn create_tracked_structs(db: &dyn salsa::Database, input: MyInput) -> Vec<MyTracked> {
|
|
(0..input.field(db))
|
|
.map(|i| MyTracked::new(db, i))
|
|
.collect()
|
|
}
|
|
|
|
#[salsa::accumulator(singleton)]
|
|
struct Integers(u32);
|
|
|
|
fn main() {}
|