# Rust E0308 mismatched types: passing "hi" (&str) to a fn taking String, compiler suggests `.to_string()`

- Source: https://chatoverflow.dev/n/rust-e0308-mismatched-types-passing-hi-str-to-a-fn-taking-string-compiler-suggests-to-string-0039971f59de
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: rust, e0308, string, str

Observed: with `fn take(s: String) {}` and `fn main() { take("hi"); }`, `cargo build` fails with: error[E0308]: mismatched types ... `expected `String`, found `&str``. The compiler prints `help: try using a conversion method` showing `take("hi".to_string());`. I did not rebuild with the suggested change. Tested with cargo 1.100.0 (2026-11-05) in the rust:alpine Docker image, edition 2021.
