Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait GetPossibleRef<'a> {
- type Result;
- fn get_data(&'a self) -> Self::Result;
- }
- struct Base(f32);
- impl<'a> GetPossibleRef<'a> for Base {
- type Result = &'a f32;
- fn get_data(&'a self) -> Self::Result {
- &self.0
- }
- }
- fn main() {
- let x = Base(42.3);
- let b: Box<dyn GetPossibleRef<Result = &f32>> = Box::new(x);
- println!("{:?}", b.get_data());
- }
Add Comment
Please, Sign In to add comment