Skip to content

Commit

Permalink
Fix sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Mar 20, 2023
1 parent 8750406 commit 444fe13
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,21 @@ If you need support for conversions from these values, you should use `TryFromPr

- This means, for instance, that the following is UB:

```rust ,no_run
```rust,no_run
use num_enum::UnsafeFromPrimitive;
#[derive(UnsafeFromPrimitive)]
#[repr(u8)]
enum Number {
Zero = 0,
// same for `#[num_enum(catch_all)]`, and `#[num_enum(alternatives = [2, ...])]`
#[default]
// Same for `#[num_enum(catch_all)]`, and `#[num_enum(alternatives = [2, ...])]`
#[num_enum(default)]
One = 1,
}
let _undefined_behavior = unsafe { Number::unchecked_transmute_from(2) };
```

```rust
use num_enum::UnsafeFromPrimitive;

Expand Down

0 comments on commit 444fe13

Please sign in to comment.