Closed marioortizmanero closed 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>`
Whoops, sorry about that. I completely misread Box::into_inner
.
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.