summaryrefslogtreecommitdiff
path: root/compiler/rustc_data_structures/src/owned_slice/tests.rs
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-05-17 11:13:55 +0530
committerGitHub <noreply@github.com>2023-05-17 11:13:55 +0530
commit2a5c4baf68ef935be5948c86934aa7519e663704 (patch)
tree81deb1ae7bfcef9d7bf79bb5c0ba419b45a81687 /compiler/rustc_data_structures/src/owned_slice/tests.rs
parentc0784db3deddfb09f52c65373ef50b14d82494cc (diff)
parenta6197a5dcad33acd67a8455196b8dbaab525e3f9 (diff)
downloadrust-2a5c4baf68ef935be5948c86934aa7519e663704.tar.gz
Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb
Share slice of bytes r? `@Nilstrieb` cc `@noamtashma`
Diffstat (limited to 'compiler/rustc_data_structures/src/owned_slice/tests.rs')
-rw-r--r--compiler/rustc_data_structures/src/owned_slice/tests.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_data_structures/src/owned_slice/tests.rs b/compiler/rustc_data_structures/src/owned_slice/tests.rs
index e151b8c2de0..1eb5378cd1a 100644
--- a/compiler/rustc_data_structures/src/owned_slice/tests.rs
+++ b/compiler/rustc_data_structures/src/owned_slice/tests.rs
@@ -26,7 +26,7 @@ fn static_storage() {
}
#[test]
-fn slice_the_slice() {
+fn slice_owned_the_slice() {
let slice = slice_owned(vec![1, 2, 3, 4, 5, 6], Vec::as_slice);
let slice = slice_owned(slice, |s| &s[1..][..4]);
let slice = slice_owned(slice, |s| s);
@@ -36,6 +36,16 @@ fn slice_the_slice() {
}
#[test]
+fn slice_the_slice() {
+ let slice = slice_owned(vec![1, 2, 3, 4, 5, 6], Vec::as_slice)
+ .slice(|s| &s[1..][..4])
+ .slice(|s| s)
+ .slice(|s| &s[1..]);
+
+ assert_eq!(&*slice, &[1, 2, 3, 4, 5, 6][1..][..4][1..]);
+}
+
+#[test]
fn try_and_fail() {
let res = try_slice_owned(vec![0], |v| v.get(12..).ok_or(()));