-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust Number/String/pointer/usize/chart 内置属性 #773
Comments
String通用
|
pointer 指针https://doc.rust-lang.org/std/primitive.pointer.html 方法
// Iterate using a raw pointer in increments of two elements
let data = [1u8, 2, 3, 4, 5];
let mut ptr: *const u8 = data.as_ptr();
let step = 2;
let end_rounded_up = ptr.wrapping_add(6);
// This loop prints "1, 3, 5, "
while ptr != end_rounded_up {
unsafe {
print!("{}, ", *ptr);
}
ptr = ptr.wrapping_add(step);
}
|
usize/isize
方法
|
char
let x = 'x';
let two_hearts = ' '; 不像其他语言,这意味着Rust的字符不是单个字节,而是四个。 方法encode_utf16 |
总结
Number
通用
https://doc.rust-lang.org/nightly/std/primitive.i32.html#method.wrapping_add
环绕该数据类型边界进行加减,比如边界是100,则100+2 === 2
f32
The text was updated successfully, but these errors were encountered: