mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
19 lines
354 B
Rust
19 lines
354 B
Rust
#![allow(rust_2021_compatibility)]
|
|
|
|
pub trait Foo {}
|
|
|
|
struct FooA {}
|
|
impl Foo for FooA {}
|
|
|
|
struct FooB {}
|
|
impl Foo for FooB {}
|
|
|
|
// dyn keyword is available in 2018+
|
|
pub fn make_foo(value: i32) -> Box<dyn Foo> {
|
|
match value {
|
|
// Unsupported in 2021+, should be 0..=42
|
|
0...42 => Box::new(FooA{}),
|
|
_ => Box::new(FooB{}),
|
|
}
|
|
}
|