pub fn first_abs_path_from_str(s: &str) -> Result<PathBuf, Box<dyn Error>>
Expand description
Parse an absolute path from a string. This assumes that the the first ‘/’ found in the string is the start of the path.
§Example
use std::path::PathBuf;
let test_str = r#" ERROR: Logfile of failure stored in: /app/yocto/build/tmp/work/x86_64-linux/sqlite3-native/3.43.2/temp/log.do_fetch.21616"#;
let path = first_abs_path_from_str(test_str).unwrap();
assert_eq!(
path,
PathBuf::from("/app/yocto/build/tmp/work/x86_64-linux/sqlite3-native/3.43.2/temp/log.do_fetch.21616")
);
§Errors
This function returns an error if no ‘/’ is found in the string or if the path is not a valid path.