debian/rust-vendor/link-section/tests/target-test/link-section-const.rs
raw| 1 | use link_section::declarative::{section, in_section}; |
| 2 | use link_section::TypedSection; |
| 3 | |
| 4 | struct Driver { |
| 5 | name: &'static str, |
| 6 | f: fn(), |
| 7 | } |
| 8 | |
| 9 | impl Driver { |
| 10 | const fn new(name: &'static str, f: fn()) -> Self { |
| 11 | Self { name, f } |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | section! { |
| 16 | #[section(unsafe, type = typed)] |
| 17 | static FOO: TypedSection<Driver>; |
| 18 | } |
| 19 | |
| 20 | in_section! { |
| 21 | #[in_section(unsafe, type = typed, name = FOO)] |
| 22 | const DRIVER: Driver = Driver::new("driver", || ()); |
| 23 | } |
| 24 | |
| 25 | fn main() { |
| 26 | } |