pub fn to_path_buf<P: AsRef<Path>>(path: P) -> PathBuf
Expand description
Converts a path to a PathBuf
.
§Arguments
path
- The path to convert (can be a&str
,String
,Path
, orPathBuf
).
§Returns
A PathBuf
representation of the path.
§Examples
§Using a string literal
use file_io::to_path_buf;
use std::path::PathBuf;
let path: &str = "folder/subfolder_9/file.txt";
let path_buf: PathBuf = to_path_buf(path);
§Using a Path
reference
use file_io::to_path_buf;
use std::path::{Path, PathBuf};
let path: &Path = Path::new("folder/subfolder_10/file.txt");
let path_buf: PathBuf = to_path_buf(path);