You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[RFC] initialize singletons at runtime
This PR changes how the singletons are initialized. The advantage of initializing a singleton at
runtime is that the initial value is not constrained to only what works in const context. The
disadvantage is that this approach will use up more Flash. With the new approach, `singleton!(_:
[u8; 1024] = [0; 1024])` will invoke a memcpy at the caller site; with the old approach, the array
would have been initialized (zeroed) during startup.
The following code works with the new approach, but doesn't with the old one.
``` rust
let x = 0;
let y = singleton!(_: u32 = x);
```
cc @therealprof@hannobraun
0 commit comments