-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #67964 - JohnTitor:rollup-pu5kosl, r=JohnTitor
Rollup of 13 pull requests Successful merges: - #67566 (Add an unstable conversion from thread ID to u64) - #67671 (Account for `type X = impl Trait;` in lifetime suggestion) - #67727 (Stabilise vec::remove_item) - #67877 (Omit underscore constants from rustdoc) - #67880 (Handle multiple error fix suggestions carefuly) - #67898 (Improve hygiene of `newtype_index`) - #67908 (rustdoc: HTML escape const values) - #67909 (Fix ICE in const pretty printing and resolve FIXME) - #67929 (Formatting an example for method Vec.retain) - #67934 (Clean up E0178 explanation) - #67936 (fire "non_camel_case_types" for associated types) - #67943 (Missing module std in example.) - #67962 (Update books) Failed merges: r? @ghost
- Loading branch information
Showing
46 changed files
with
237 additions
and
117 deletions.
There are no files selected for viewing
Submodule book
updated
2 files
+1 −1 | src/ch07-00-managing-growing-projects-with-packages-crates-and-modules.md | |
+19 −13 | src/ch11-02-running-tests.md |
Submodule reference
updated
4 files
+3 −2 | src/abi.md | |
+8 −8 | src/expressions/closure-expr.md | |
+1 −1 | src/identifiers.md | |
+1 −1 | src/macros-by-example.md |
Submodule rust-by-example
updated
3 files
+3 −0 | book.toml | |
+2 −2 | src/error/multiple_error_types/boxing_errors.md | |
+14 −2 | src/trait/impl_trait.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![allow(dead_code)] | ||
newtype_index!(struct MyIdx { MAX = 0xFFFF_FFFA }); | ||
|
||
#[test] | ||
fn index_size_is_optimized() { | ||
use std::mem::size_of; | ||
|
||
assert_eq!(size_of::<MyIdx>(), 4); | ||
// Uses 0xFFFF_FFFB | ||
assert_eq!(size_of::<Option<MyIdx>>(), 4); | ||
// Uses 0xFFFF_FFFC | ||
assert_eq!(size_of::<Option<Option<MyIdx>>>(), 4); | ||
// Uses 0xFFFF_FFFD | ||
assert_eq!(size_of::<Option<Option<Option<MyIdx>>>>(), 4); | ||
// Uses 0xFFFF_FFFE | ||
assert_eq!(size_of::<Option<Option<Option<Option<MyIdx>>>>>(), 4); | ||
// Uses 0xFFFF_FFFF | ||
assert_eq!(size_of::<Option<Option<Option<Option<Option<MyIdx>>>>>>(), 4); | ||
// Uses a tag | ||
assert_eq!(size_of::<Option<Option<Option<Option<Option<Option<MyIdx>>>>>>>(), 8); | ||
} | ||
|
||
#[test] | ||
fn range_iterator_iterates_forwards() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!( | ||
range.collect::<Vec<_>>(), | ||
[MyIdx::from_u32(1), MyIdx::from_u32(2), MyIdx::from_u32(3)] | ||
); | ||
} | ||
|
||
#[test] | ||
fn range_iterator_iterates_backwards() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!( | ||
range.rev().collect::<Vec<_>>(), | ||
[MyIdx::from_u32(3), MyIdx::from_u32(2), MyIdx::from_u32(1)] | ||
); | ||
} | ||
|
||
#[test] | ||
fn range_count_is_correct() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!(range.count(), 3); | ||
} | ||
|
||
#[test] | ||
fn range_size_hint_is_correct() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!(range.size_hint(), (3, Some(3))); | ||
} |
Oops, something went wrong.