diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2022-11-18 17:48:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-18 17:48:16 -0500 |
| commit | 8aca6ccedd0916da959638e6d2aac610d11e79c5 (patch) | |
| tree | 3dd002a36395cd4f3d145b1adde338317a071016 /src/test/ui/array-slice-vec | |
| parent | 70fe5f08fffd16dc20506f7d140e47b074f77964 (diff) | |
| parent | f3d7b39cdf483ae543757fbef369c166650e66f2 (diff) | |
| download | rust-8aca6ccedd0916da959638e6d2aac610d11e79c5.tar.gz rust-8aca6ccedd0916da959638e6d2aac610d11e79c5.zip | |
Rollup merge of #102977 - lukas-code:is-sorted-hrtb, r=m-ou-se
remove HRTB from `[T]::is_sorted_by{,_key}`
Changes the signature of `[T]::is_sorted_by{,_key}` to match `[T]::binary_search_by{,_key}` and make code like https://github.com/rust-lang/rust/issues/53485#issuecomment-885393452 compile.
Tracking issue: https://github.com/rust-lang/rust/issues/53485
~~Do we need an ACP for something like this?~~ Edit: Filed ACP here: https://github.com/rust-lang/libs-team/issues/121
Diffstat (limited to 'src/test/ui/array-slice-vec')
| -rw-r--r-- | src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs b/src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs new file mode 100644 index 00000000000..073280d0fab --- /dev/null +++ b/src/test/ui/array-slice-vec/slice_is_sorted_by_borrow.rs @@ -0,0 +1,20 @@ +// check-pass +// regression test for https://github.com/rust-lang/rust/issues/53485#issuecomment-885393452 + +#![feature(is_sorted)] + +struct A { + name: String, +} + +fn main() { + let a = &[ + A { + name: "1".to_string(), + }, + A { + name: "2".to_string(), + }, + ]; + assert!(a.is_sorted_by_key(|a| a.name.as_str())); +} |
