We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 981cb8c commit e699e83Copy full SHA for e699e83
src/test/codegen/slice-windows-no-bounds-check.rs
@@ -0,0 +1,35 @@
1
+#![crate_type = "lib"]
2
+
3
+// compile-flags: -O
4
5
+use std::slice::Windows;
6
7
+// CHECK-LABEL: @naive_string_search
8
+#[no_mangle]
9
+pub fn naive_string_search(haystack: &str, needle: &str) -> Option<usize> {
10
+ if needle.is_empty() {
11
+ return Some(0);
12
+ }
13
+ // CHECK-NOT: panic
14
+ // CHECK-NOT: fail
15
+ haystack
16
+ .as_bytes()
17
+ .windows(needle.len())
18
+ .position(|sub| sub == needle.as_bytes())
19
+}
20
21
+// CHECK-LABEL: @next
22
23
+pub fn next<'a>(w: &mut Windows<'a, u32>) -> Option<&'a [u32]> {
24
25
26
+ w.next()
27
28
29
+// CHECK-LABEL: @next_back
30
31
+pub fn next_back<'a>(w: &mut Windows<'a, u32>) -> Option<&'a [u32]> {
32
33
34
+ w.next_back()
35
0 commit comments