rodrimati1992 / abi_stable_crates

Rust-to-Rust ffi,ffi-safe equivalents of std types,and creating libraries loaded at startup.
Apache License 2.0
528 stars 30 forks source link

`RBox::into_inner` should use `self` rather than `this: Self` #74

Closed marioortizmanero closed 2 years ago

marioortizmanero commented 2 years ago

The function was weird to use otherwise for no reason in particular. It's the same as Box now as well: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.into_inner.

rodrimati1992 commented 2 years ago

It's a non-method associated function for the same reason as Box::into_inner.

Box::into_inner cannot be called as a method: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=a10afb3524c8f99be7e5468b81df38e6

fn main(){
    let boxed = Box::new(100u8);
    boxed.into_inner();
}
error[E0599]: no method named `into_inner` found for struct `Box<u8>` in the current scope
 --> src/main.rs:3:11
  |
3 |     boxed.into_inner();
  |     ------^^^^^^^^^^
  |     |     |
  |     |     this is an associated function, not a method
  |     help: use associated function syntax instead: `Box::<u8>::into_inner`
  |
  = 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 `Box<T, A>`
marioortizmanero commented 2 years ago

Whoops, sorry about that. I completely misread Box::into_inner.