0

How do I resolve this? The execution is a return from process::Command .output().

let mut gradinglog = std::str::from_utf8(&execution.stdout).unwrap().to_string() + 
std::str::from_utf8(&execution.stderr).unwrap().to_string();

Compilation error log:

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()`
ArekBulski
  • 4,520
  • 4
  • 39
  • 61
  • 1
    Does the *"help:"* annotation in the error message not solve your problem? An alternative solution is to drop the last `.to_string()` since `str::from_utf8().unwrap()` already returns a `&str`. – kmdreko Apr 18 '21 at 21:43
  • Yes it does. And they show using format() too. – ArekBulski Apr 18 '21 at 22:16

1 Answers1

0

Ah this is strange but... I managed to concatenate using a simple format!("{}{}", string1, string2);

ArekBulski
  • 4,520
  • 4
  • 39
  • 61