File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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
+ #[ no_mangle]
23
+ pub fn next < ' a > ( w : & mut Windows < ' a , u32 > ) -> Option < & ' a [ u32 ] > {
24
+ // CHECK-NOT: panic
25
+ // CHECK-NOT: fail
26
+ w. next ( )
27
+ }
28
+
29
+ // CHECK-LABEL: @next_back
30
+ #[ no_mangle]
31
+ pub fn next_back < ' a > ( w : & mut Windows < ' a , u32 > ) -> Option < & ' a [ u32 ] > {
32
+ // CHECK-NOT: panic
33
+ // CHECK-NOT: fail
34
+ w. next_back ( )
35
+ }
You can’t perform that action at this time.
0 commit comments