Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Trait {
- fn bar(&self);
- }
- struct A<T: Trait> {
- a: T,
- }
- struct B<T: Trait> {
- b: Option<A<T>>,
- }
- struct C;
- impl C {
- fn new() -> Self {
- Self {}
- }
- }
- impl Trait for C {
- fn bar(&self) {
- }
- }
- impl<T: Trait> A<T> {
- fn new(a: T) -> Self {
- Self {
- a
- }
- }
- }
- impl<T: Trait> B<T> {
- fn new() -> Self {
- Self {
- b: None,
- }
- }
- fn process(&mut self) {
- self.b = Some(A::new(C::new()));
- }
- }
- fn main() {
- let b = B::new();
- b.process();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement