Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- let b = Box::new([1, 2]) as Box<[u8]>; let ptr = b.into_raw(); let s = ::std::slice::from_raw_parts(ptr, 2); Box::from_raw(s)
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0599]: no method named `into_raw` found for type `std::boxed::Box<[u8]>` in the current scope
- --> src/main.rs:6:60
- |
- 6 | let b = Box::new([1, 2]) as Box<[u8]>; let ptr = b.into_raw(); let s = ::std::slice::from_raw_parts(ptr, 2); Box::from_raw(s)
- | --^^^^^^^^
- | | |
- | | this is an associated function, not a method
- | help: use associated function syntax instead: `std::boxed::Box<[u8]>::into_raw`
- |
- = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
- = note: the candidate is defined in an impl for the type `std::boxed::Box<_>`
- error[E0308]: mismatched types
- --> src/main.rs:6:132
- |
- 6 | let b = Box::new([1, 2]) as Box<[u8]>; let ptr = b.into_raw(); let s = ::std::slice::from_raw_parts(ptr, 2); Box::from_raw(s)
- | ^ types differ in mutability
- |
- = note: expected type `*mut _`
- found type `&[_]`
- error: aborting due to 2 previous errors
- Some errors occurred: E0308, E0599.
- For more information about an error, try `rustc --explain E0308`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement