[英]What does double colon mean in Rust?
I'm completely new to Rust programming language.我对 Rust 编程语言完全陌生。 While studying this lesson , I kind of didn't understand the following two lines.
在学习本课时,我有点不明白以下两行。
let mut guess = String::new();
and,和,
io::stdin()
What is the use of double colon in both cases?在这两种情况下双冒号的用途是什么?
::
behaves like a namespace accessor. ::
行为类似于命名空间访问器。 You can navigate through modules or specify locations like std::io::stdin()
or call methods for objects like in String::new()
.您可以浏览模块或指定位置,如
std::io::stdin()
或调用对象的方法,如String::new()
。 It can even be mixed, since an object may be in a module itself, so for example, the full path to the String new method would be std::string::String::new
.它甚至可以混合使用,因为一个对象可能在一个模块本身中,例如,String new 方法的完整路径将是
std::string::String::new
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.