SHARE
TWEET

Untitled

a guest Apr 21st, 2019 168 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5.     println!("{:?}", {
  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)
  7.     });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12.    Compiling playground v0.0.1 (/playground)
  13. error[E0599]: no method named `into_raw` found for type `std::boxed::Box<[u8]>` in the current scope
  14.  --> src/main.rs:6:60
  15.   |
  16. 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)
  17.   |                                                          --^^^^^^^^
  18.   |                                                          | |
  19.   |                                                          | this is an associated function, not a method
  20.   |                                                          help: use associated function syntax instead: `std::boxed::Box<[u8]>::into_raw`
  21.   |
  22.   = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
  23.   = note: the candidate is defined in an impl for the type `std::boxed::Box<_>`
  24.  
  25. error[E0308]: mismatched types
  26.  --> src/main.rs:6:132
  27.   |
  28. 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)
  29.   |                                                                                                                                    ^ types differ in mutability
  30.   |
  31.   = note: expected type `*mut _`
  32.              found type `&[_]`
  33.  
  34. error: aborting due to 2 previous errors
  35.  
  36. Some errors occurred: E0308, E0599.
  37. For more information about an error, try `rustc --explain E0308`.
  38. error: Could not compile `playground`.
  39.  
  40. To learn more, run the command again with --verbose.
  41.  
  42. */
  43.  
  44. /* ~~~~=== stdout ===~~~~
  45.  
  46. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top