Fix the issue of duplicate unique ID for atoms using newtype.

The MergeFunctionsPass in LLVM merges identical functions (https://rust.godbolt.org/z/3nnr9nMne), resulting in the same function addresses.
This commit is contained in:
DianQK committed 2023-06-21 21:50:10 +08:00
1 parent 9731640434
commit 535435a4cf
14 files changed
+74 -52

No files matched your search

@@ -113,14 +113,14 @@ enum InputError {
TooShort,
}
static INPUT_ERROR: Atom<InputError> = |_| InputError::None;
static INPUT_ERROR: Atom<InputError> = Atom(|_| InputError::None);
```
Então, em nosso componente de nível superior, queremos tratar explicitamente o possível estado de erro para esta parte da árvore.
```rust
fn TopLevel(cx: Scope) -> Element {
let error = use_read(cx, INPUT_ERROR);
let error = use_read(cx, &INPUT_ERROR);
match error {
TooLong => return cx.render(rsx!{ "FAILED: Too long!" }),
@@ -134,7 +134,7 @@ Agora, sempre que um componente _downstream_ tiver um erro em suas ações, ele
```rust
fn Commandline(cx: Scope) -> Element {
let set_error = use_set(cx, INPUT_ERROR);
let set_error = use_set(cx, &INPUT_ERROR);
cx.render(rsx!{
input {