crax_utils 0.1.9

Some common utils
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::path::PathBuf;

/// copy from https://github.com/rolldown/rolldown/blob/main/crates/rolldown_utils/src/path_buf_ext.rs
///
/// under MIT https://github.com/rolldown/rolldown/blob/main/LICENSE
pub trait PathBufExt {
    fn expect_into_string(self) -> String;
}

impl PathBufExt for std::path::PathBuf {
    fn expect_into_string(self) -> String {
        self.into_os_string().into_string().unwrap_or_else(|input| {
            panic!("Failed to convert {:?} to valid utf8 string", PathBuf::from(input).display());
        })
    }
}