Messages in this thread | | | From | Wedson Almeida Filho <> | Date | Mon, 1 Apr 2024 20:21:45 -0300 | Subject | Re: [PATCH] rust: types: Make Opaque::get const |
| |
On Mon, 1 Apr 2024 at 18:46, Boqun Feng <boqun.feng@gmail.com> wrote: > > To support a potential usage: > > static foo: Opaque<Foo> = ..; // Or defined in an extern block. > > ... > > fn bar() { > let ptr = foo.get(); > } > > `Opaque::get` need to be `const`, otherwise compiler will complain > because calls on statics are limited to const functions. > > Also `Opaque::get` should be naturally `const` since it's a composition > of two `const` functions: `UnsafeCell::get` and `ptr::cast`. > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Wedson Almeida Filho <walmeida@microsoft.com>
| |