Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::sync::Arc;
- trait A: AsA {}
- trait B: A {}
- trait AsA {
- fn as_a(&self) -> &A;
- }
- impl<T: A> AsA for T {
- fn as_a(&self) -> &A {
- self
- }
- }
- struct Y;
- impl A for Y {}
- impl B for Y {}
- fn another(x: &dyn A){ }
- fn something(x: Arc<dyn B>) {
- another(x.as_a());
- }
- fn main() {
- let y = Y;
- something(Arc::new(y));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement