Elektrine lite

← Feed

@luna@lunar.place

Post #2612506

2023-12-02 21:04 UTC

@janriemer@floss.social Isn't &Box and &T identical?

Replies (1)

  • @janriemer@floss.social 2023-12-02 21:21

    @luna@lunar.place I think in the case of `&Box` deref coercion happens under the hood, so yes it works too, but in the end the method is called on `&dyn ...`, not &Box. Simple example to show that one can call trait object methods on &Box (via automatic deref coercion): https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b1cb5a760c46da62bca9be0e1a8d28f5

    Open ##2612507