string - Rust:连接两个 expr.to_string() 值
问题描述
我该如何解决这个问题?执行是从 process::Command .output() 返回的。
let mut gradinglog = std::str::from_utf8(&execution.stdout).unwrap().to_string() +
std::str::from_utf8(&execution.stderr).unwrap().to_string();
编译错误日志:
error[E0308]: mismatched types
--> src/main.rs:270:87
|
270 | ...rap().to_string() + std::str::from_utf8(&execution.stderr).unwrap().to_string();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected `&str`, found struct `std::string::String`
| help: consider borrowing here: `&std::str::from_utf8(&execution.stderr).unwrap().to_string()`
解决方案
啊,这很奇怪,但是...我设法使用简单的格式进行连接!("{}{}", string1, string2);
推荐阅读
- c# - C# .Net.Sockets Onreceive 部分有效
- r - r - 如何根据排名改变行的位置
- vba - 如何在给定条件下在 VBA 中显示月份
- html - 页脚问题
- r - 计算 Hawk 过程梯度的有效方法
- google-app-engine - 无法删除 google-app-engine 中的 Datastore 实体
- pytorch - 尺寸超出范围(预计在 [-2, 1] 范围内,但得到 2)
- php - 更新数组内的数组键
- iphone - 是否有任何应用程序可以将 Mac 桌面作为 VR 流式传输到 iPhone
- typescript - 将函数 reduce 应用于空数组时的问题