Replies: 1 comment 1 reply
-
这两种方式不一样的,你可能对这俩 你看看下面的例子。 static CONST_INTEGER_WITH_STATIC_LIFETIME: i32 = 12345;
let ref_with_static_lifetime: &'static i32 = &54321; // error
fn main(){
println!("Static constant: {}", CONST_INTEGER_WITH_STATIC_LIFETIME);
println!("Static referenced value: {}", &ref_with_static_lifetime);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
你好,我在阅读静态变量文档时想到一个小提议,就是在定义静态变量时有两种方式,如下:
通常定义静态变量的时候可能都会选择第一种方式,但是第二种显然也可行,这样的话需不需要对定义静态变量也加一个规范?
Beta Was this translation helpful? Give feedback.
All reactions