mirror of
https://github.com/rust-unofficial/patterns
synced 2024-11-16 12:13:24 +00:00
Update patterns/unsafe-mods.md
Co-Authored-By: llogiq <bogusandre@gmail.com>
This commit is contained in:
parent
a6879dbe97
commit
aa886569ed
@ -17,7 +17,7 @@ If you have `unsafe` code, create the smallest possible module that can uphold t
|
|||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
* The [`optional`](https://crates.io/crates/optional) crate has one unsafe module for converting a `&T` to either a slice of one `[T]` or an empty slice.
|
* The [`optional`](https://crates.io/crates/optional) crate has one unsafe module for converting a `&T` to either a slice of one `[T]` or an empty slice.
|
||||||
* `std`s `String` class is basically just a wrapper over `Vec<u8>` with the added invariant that the contents must be valid unicode. The operations on `String` ensure this behavior, however, users have the option of using an `unsafe` method to create a `String`, in which case the onus is on them to guarantee the validity of the contents.
|
* `std`s `String` class is a wrapper over `Vec<u8>` with the added invariant that the contents must be valid UTF-8. The operations on `String` ensure this behavior. However, users have the option of using an `unsafe` method to create a `String`, in which case the onus is on them to guarantee the validity of the contents.
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user