Re: [PATCH] rust: types: Make Opaque::get const
From: Benno Lossin
Date: Tue Apr 02 2024 - 08:50:35 EST
On 01.04.24 23:45, Boqun Feng 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@xxxxxxxxx>
> ---
> rust/kernel/types.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Benno Lossin <benno.lossin@xxxxxxxxx>
--
Cheers,
Benno