pub fn load_unchecked<P: Into<Option<String>>>(path: P) -> anyhow::Result<Self> {
        let opt_path = path.into();
        let paths = vec![
            opt_path.clone(),
            std::env::var("CONFIG_PATH").ok(),
            Some(CONFIG_PATH.to_string()),
        ]
        .into_iter();
        for path in paths.filter_map(|v| v) {
            match std::fs::File::open(Path::new(&path)) {
                Ok(f) => return ron::de::from_reader(f).map_err(|e| anyhow!(e)),
                Err(e) => match e.kind() {
                    std::io::ErrorKind::NotFound => {
                        continue;
                    }
                    _ => bail!(e.to_string()),
                },
            }
        }
        let path = opt_path
            .or_else(|| std::env::var("CONFIG_PATH").ok())
            .unwrap_or(CONFIG_PATH.to_string());
        let config = Self::default();
        config.save(path.clone())?;
        bail!(
            "Config file was not found! Saving a default config file at {}. Please edit it and restart the application!",
            std::fs::canonicalize(&path).map(|p| p.to_string_lossy().into_owned()).unwrap_or(path)
        );
    }
/// Load versioned config from a RON file without checking the version. Will check the
/// following paths in this order:
/// 1. Provided path
/// 2. Environment variable CONFIG_PATH
/// 3. Default config path: ./config.ron
Load versioned config from a RON file without checking the version. Will check the
following paths in this order:
1. Provided path
2. Environment variable CONFIG_PATH
3.
Load versioned config from a RON file without checking the version . Will check the following paths in this order : 1 . Provided path 2 . Environment variable CONFIG_PATH 3 .
pub fn load_unchecked<P: Into<Option<String>>>(path: P) -> anyhow::Result<Self> {
        let opt_path = path.into();
        let paths = vec![
            opt_path.clone(),
            std::env::var("CONFIG_PATH").ok(),
            Some(CONFIG_PATH.to_string()),
        ]
        .into_iter();
        for path in paths.filter_map(|v| v) {
            match std::fs::File::open(Path::new(&path)) {
                Ok(f) => return ron::de::from_reader(f).map_err(|e| anyhow!(e)),
                Err(e) => match e.kind() {
                    std::io::ErrorKind::NotFound => {
                        continue;
                    }
                    _ => bail!(e.to_string()),
                },
            }
        }
        let path = opt_path
            .or_else(|| std::env::var("CONFIG_PATH").ok())
            .unwrap_or(CONFIG_PATH.to_string());
        let config = Self::default();
        config.save(path.clone())?;
        bail!(
            "Config file was not found! Saving a default config file at {}. Please edit it and restart the application!",
            std::fs::canonicalize(&path).map(|p| p.to_string_lossy().into_owned()).unwrap_or(path)
        );
    }
pub fn load_unchecked < P : Into < Option < String > > > ( path : P ) -> anyhow :: Result < Self > { let opt_path = path . into ( ) ; let paths = vec ! [ opt_path clone ( ) std env var ( " " ) ok ( ) Some ( CONFIG_PATH to_string ( ) ) ] . into_iter ( ) ; for path in paths . filter_map ( | v | v ) { match std :: fs :: File :: open ( Path :: new ( & path ) ) { Ok ( f ) => return ron :: de :: from_reader ( f ) . map_err ( | e | anyhow ! ( e ) ) , Err ( e ) => match e . kind ( ) { std :: io :: ErrorKind :: NotFound => { continue ; } _ => bail ! ( e to_string ( ) ) , } , } } let path = opt_path . or_else ( | | std :: env :: var ( " " ) . ok ( ) ) . unwrap_or ( CONFIG_PATH . to_string ( ) ) ; let config = Self :: default ( ) ; config . save ( path . clone ( ) ) ? ; bail ! ( " " std fs canonicalize ( path ) map ( p p to_string_lossy ( ) into_owned ( ) ) unwrap_or ( path ) ) ; }
Load versioned config from a RON file without checking the version.
Load versioned config from a RON file without checking the version .
path
P