fn from_path<U: AsRef<std::path::Path>>(fp: &U) -> FileResult<'_, Self> {
        use std::{ffi::OsStr, fs};

        let ext = fp
            .as_ref()
            .extension()
            .and_then(OsStr::to_str)
            .unwrap_or_default();

        match ext {
            // Reads the file as an OFF file.
            "off" => match String::from_utf8(fs::read(fp)?) {
                Ok(src) => Ok(Self::from_off(&src)?),
                Err(err) => Err(err.into()),
            },

            // Reads the file as a GGB file.
            "ggb" => Ok(Self::from_ggb(fs::File::open(fp)?)?),

            // Could not recognize the file extension.
            ext => Err(FileError::InvalidExtension(ext)),
        }
    }
/// Loads a polytope from a file path.
Loads a polytope from a file path.
Loads a polytope from a file path .
fn from_path<U: AsRef<std::path::Path>>(fp: &U) -> FileResult<'_, Self> {
        use std::{ffi::OsStr, fs};
        let ext = fp
            .as_ref()
            .extension()
            .and_then(OsStr::to_str)
            .unwrap_or_default();
        match ext {
            // Reads the file as an OFF file.
            "off" => match String::from_utf8(fs::read(fp)?) {
                Ok(src) => Ok(Self::from_off(&src)?),
                Err(err) => Err(err.into()),
            },
            // Reads the file as a GGB file.
            "ggb" => Ok(Self::from_ggb(fs::File::open(fp)?)?),
            // Could not recognize the file extension.
            ext => Err(FileError::InvalidExtension(ext)),
        }
    }
fn from_path < U : AsRef < std :: path :: Path > > ( fp : & U ) -> FileResult < ' _ , Self > { use std :: { ffi :: OsStr , fs } ; let ext = fp . as_ref ( ) . extension ( ) . and_then ( OsStr :: to_str ) . unwrap_or_default ( ) ; match ext { // Reads the file as an OFF file. " " => match String :: from_utf8 ( fs :: read ( fp ) ? ) { Ok ( src ) => Ok ( Self :: from_off ( & src ) ? ) , Err ( err ) => Err ( err . into ( ) ) , } , // Reads the file as a GGB file. " " => Ok ( Self :: from_ggb ( fs :: File :: open ( fp ) ? ) ? ) , // Could not recognize the file extension. ext => Err ( FileError :: InvalidExtension ( ext ) ) , } }
Loads a polytope from a file path.
Loads a polytope from a file path .
fp
&U
fp
&U