lkml.org 
[lkml]   [2024]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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>

\
 
 \ /
  Last update: 2024-05-27 16:18    [W:0.078 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site