I have to convert the PathBuf variable to a String to feed my function. My code is like this:
let cwd = env::current_dir().unwrap()
As mcarton already say is not so simple and not all path are UTF-8 encoded. But you can use:
p.into_os_string().into_string()
To have a fine control of it. By ? you can send error to upper level or simply ignore it by unwrap():
let my_str = cwd.into_os_string().into_string().unwrap();
The beauty thing about into_string() is that the error wrap the original OsString value.