我很新于Rust语言,正在尝试编写一个命令行实用程序来学习。我正在获取
这会导致出现此错误。
args
列表并尝试匹配它们。let args = os::args()
//some more code
match args[1].into_ascii_lower().as_slice() {
"?" | "help" => { //show help },
"add" => { //do other stuff },
_ => { //do default stuff }
}
这会导致出现此错误。
cannot move out of dereference (dereference is implicit, due to indexing)
match args[1].into_ascii_lower().as_slice() {
^~~~~~~
我不知道那是什么意思,但搜索结果发现这篇文章,虽然没看懂,但是将args[1]
改为args.get(1)
后还是出现了另一个错误。
error: cannot move out of dereference of `&`-pointer
match args.get(1).into_ascii_lower().as_slice() {
^~~~~~~~~~~
发生了什么事?