相关疑难解决方法(0)

反转str.split的结果

加入https://doc.rust-lang.org/std/str/struct.Split.html有一个关于字符串rev结果的方法split

我收到以下错误

error: the trait `core::str::pattern::DoubleEndedSearcher<'_>` is not
implemented for the type `core::str::pattern::StrSearcher<'_, '_>` [E0277]
for part in "1:30".split(":").rev() {
Run Code Online (Sandbox Code Playgroud)

我用过的代码

let mut length = 0;
let mut mult = 1;
for part in "1:30".split(":").rev() {
   length += mult * part.parse::<i32>().unwrap();
   mult *= 60;
}
Run Code Online (Sandbox Code Playgroud)

string string-parsing rust

4
推荐指数
2
解决办法
471
查看次数

标签 统计

rust ×1

string ×1

string-parsing ×1