Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from nnethercote:master #3

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/standard-library-types.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Standard Library Types

It is worth reading through the documentation for common standard library
types—such as [`Box`], [`Vec`], [`Option`], [`Result`], and [`Rc`]/[`Arc`]—to find interesting
types—such as [`Vec`], [`Option`], [`Result`], and [`Rc`]/[`Arc`]—to find interesting
functions that can sometimes be used to improve performance.

[`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
[`Vec`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
[`Option`]: https://doc.rust-lang.org/std/option/enum.Option.html
[`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
Expand All @@ -20,16 +19,6 @@ library types, such as [`Mutex`], [`RwLock`], [`Condvar`], and
[`Condvar`]: https://doc.rust-lang.org/std/sync/struct.Condvar.html
[`Once`]: https://doc.rust-lang.org/std/sync/struct.Once.html

## `Box`

The expression [`Box::default()`] has the same effect as
`Box::new(T::default())` but can be faster because the compiler can create the
value directly on the heap, rather than constructing it on the stack and then
copying it over.
[**Example**](https://github.com/komora-io/art/commit/d5dc58338f475709c375e15976d0d77eb5d7f7ef).

[`Box::default()`]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.default

## `Vec`

The best way to create a zero-filled `Vec` of length `n` is with `vec![0; n]`.
Expand Down
Loading