Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Fromable {
- fn create() -> Self;
- }
- struct A;
- impl Fromable for A {
- fn create() -> Self {
- A {}
- }
- }
- fn construct<T: Fromable>() -> impl Fromable {
- T::create()
- }
- fn main() {
- let s = "'A";
- match s {
- "'A" => Some(construct::<A>()),
- _ => None
- };
- }
Add Comment
Please, Sign In to add comment