pub fn new_from_files(problem_id: &str) -> Self {
        let mut sc = SampleCases {
            input: Vec::new(),
            output: Vec::new(),
        };

        let mut dir_io_examples = PathBuf::new();
        dir_io_examples.push(format!("io_examples/{}", problem_id));

        for dir_res in fs::read_dir(dir_io_examples).unwrap() {
            let dir_name = dir_res.unwrap().path();
            // Sort i/o example files because an order of `fs::read_dir()` returns directory depends on environment.
            let mut dir_sample_case: Vec<_> = fs::read_dir(&dir_name)
                .unwrap()
                .map(|d| d.unwrap())
                .collect();
            dir_sample_case.sort_by_key(|dir| dir.path());

            for file in dir_sample_case {
                let file_content = fs::read_to_string(file.path()).unwrap();
                if dir_name.ends_with(&format!("{}_input", problem_id)) {
                    sc.input.push(file_content);
                } else {
                    sc.output.push(file_content);
                }
            }
        }
        sc
    }
/// Construct a new `SampleCases` from input/output example files.
/// This method is called in `atcoder-util test`.
Construct a new `SampleCases` from input/output example files.
This method is called in `atcoder-util test`.
Construct a new ` SampleCases ` from input / output example files . This method is called in ` atcoder - util test ` .
pub fn new_from_files(problem_id: &str) -> Self {
        let mut sc = SampleCases {
            input: Vec::new(),
            output: Vec::new(),
        };
        let mut dir_io_examples = PathBuf::new();
        dir_io_examples.push(format!("io_examples/{}", problem_id));
        for dir_res in fs::read_dir(dir_io_examples).unwrap() {
            let dir_name = dir_res.unwrap().path();
            // Sort i/o example files because an order of `fs::read_dir()` returns directory depends on environment.
            let mut dir_sample_case: Vec<_> = fs::read_dir(&dir_name)
                .unwrap()
                .map(|d| d.unwrap())
                .collect();
            dir_sample_case.sort_by_key(|dir| dir.path());
            for file in dir_sample_case {
                let file_content = fs::read_to_string(file.path()).unwrap();
                if dir_name.ends_with(&format!("{}_input", problem_id)) {
                    sc.input.push(file_content);
                } else {
                    sc.output.push(file_content);
                }
            }
        }
        sc
    }
pub fn new_from_files ( problem_id : & str ) -> Self { let mut sc = SampleCases { input : Vec :: new ( ) , output : Vec :: new ( ) , } ; let mut dir_io_examples = PathBuf :: new ( ) ; dir_io_examples . push ( format ! ( " " problem_id ) ) ; for dir_res in fs :: read_dir ( dir_io_examples ) . unwrap ( ) { let dir_name = dir_res . unwrap ( ) . path ( ) ; // Sort i/o example files because an order of `fs::read_dir()` returns directory depends on environment. let mut dir_sample_case : Vec < _ > = fs :: read_dir ( & dir_name ) . unwrap ( ) . map ( | d | d . unwrap ( ) ) . collect ( ) ; dir_sample_case . sort_by_key ( | dir | dir . path ( ) ) ; for file in dir_sample_case { let file_content = fs :: read_to_string ( file . path ( ) ) . unwrap ( ) ; if dir_name . ends_with ( & format ! ( " " problem_id ) ) { sc . input . push ( file_content ) ; } else { sc . output . push ( file_content ) ; } } } sc }
Construct a new `SampleCases` from input/output example files.
Construct a new ` SampleCases ` from input / output example files .
problem_id
&str
problem_id
&str