mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
24 lines
No EOL
791 B
Markdown
24 lines
No EOL
791 B
Markdown
# module `unsound`
|
|
|
|
Provides APIs perform unsound and unsafe operations that cannot be guaranteed safe in Erg's type system.
|
|
|
|
## `unsafe!`
|
|
|
|
Executes an `Unsafe` procedure. Just like Rust, `Unsafe` APIs cannot be called directly, but are all passed as higher-order functions to this procedure.
|
|
|
|
```python
|
|
unsound = import "unsound"
|
|
|
|
i = unsound. unsafe! do!:
|
|
# convert `Result Int` to `Int`
|
|
unsound.transmute input!().try_into(Int), Int
|
|
```
|
|
|
|
## transmit
|
|
|
|
Converts the object of the first argument to the type of the second argument. No type checking is done.
|
|
This function breaks the type safety of the type system. Please perform validation before using.
|
|
|
|
## auto_transmute
|
|
|
|
Unlike `transmute`, it automatically converts to the expected type. Works the same as Ocaml's `Obj.magic`. |