mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
21 lines
315 B
Rust
21 lines
315 B
Rust
//@ run-pass
|
|
|
|
pub struct Data<T> {
|
|
function: fn() -> T,
|
|
}
|
|
|
|
impl<T> Data<T> {
|
|
pub const fn new(function: fn() -> T) -> Data<T> {
|
|
Data {
|
|
function: function,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub static DATA: Data<i32> = Data::new(|| {
|
|
413i32
|
|
});
|
|
|
|
fn main() {
|
|
print!("{:?}", (DATA.function)());
|
|
}
|