Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Trait {}
- type Foo = dyn Trait;
- struct Bar {
- baz: Vec<Box<Foo>>,
- }
- impl Bar {
- pub fn buzz(&self) -> &[&Foo] {
- unsafe {
- //std::slice::from_raw_parts(self.baz.as_ptr() as *const _, self.baz.len())
- &*(self.baz.as_ptr() as *const Vec<&Foo>)
- }
- }
- }
- fn main() {
- let bar = Bar { baz: vec![] };
- for _ in bar.buzz() {
- println!(".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement