Skip to content

Commit 20e5f1b

Browse files
committed
Showcase usage of paren around cast
1 parent 0bd0b27 commit 20e5f1b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

tests/unit/out/unsafe/strchr_c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub fn main() {
1212
}
1313
}
1414
unsafe fn main_0() -> i32 {
15-
let mut s: *const u8 = b"hello world\0".as_ptr().cast_mut().cast_const();
16-
let mut r: *mut u8 = libc::strchr(s as *const i8, ('w' as i32)) as *mut u8;
15+
let mut s: *const u8 = (b"hello world\0".as_ptr().cast_mut()).cast_const();
16+
let mut r: *const u8 = (libc::strchr(s as *const i8, ('w' as i32)) as *mut u8).cast_const();
1717
assert!((((!((r).is_null())) as i32) != 0));
1818
assert!((((((*r) as i32) == ('w' as i32)) as i32) != 0));
1919
assert!(((((libc::strchr(s as *const i8, ('z' as i32)) as *mut u8).is_null()) as i32) != 0));

tests/unit/strchr_c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
int main() {
66
const char *s = "hello world";
7-
char *r = strchr(s, 'w');
7+
const char *r = strchr(s, 'w');
88
assert(r != NULL);
99
assert(*r == 'w');
1010
assert(strchr(s, 'z') == NULL);

0 commit comments

Comments
 (0)