fn copy_files_from_dir(root_directory: &str, module_source_code: &mut String) {
        let path = std::path::Path::new(root_directory);
        for entry in unwrap!(path.read_dir()) {
            if let Ok(entry) = entry {
                let p: std::path::PathBuf = entry.path();
                if p.is_file() {
                    let ps = p.to_string_lossy();
                    if !ps.ends_with(".gitignore")
                        && !ps.ends_with("icon-original.png")
                        && !ps.ends_with("README.md")
                        && !ps.ends_with("package.json")
                        && !ps.ends_with("cargo_crev_reviews_wasm_bg.wasm.d.ts")
                        && !ps.ends_with("cargo_crev_reviews_wasm.d.ts")
                        && !ps.ends_with("LICENSE")
                    {
                        let start = format!(
                            "\n\"{}\" => {{\nr##\"",
                            ps.trim_start_matches("web_server_folder")
                        );
                        module_source_code.push_str(&start);

                        // binary files are encoded base64
                        let body = if ps.ends_with(".png") || ps.ends_with(".ico") || ps.ends_with(".woff2") || ps.ends_with(".wasm") {
                            let e = base64::encode(unwrap!(std::fs::read(p)));
                            // it is much easier to have lines of 76 characters in Rust source code.
                            // before decoding base64 I will eliminate \n
                            // Rust string is utf8, but base64 is strictly ascii.
                            // So I have the guarantee 100% that 1 byte = 1 char
                            let multi_line = e.as_bytes().chunks(76).collect::<Vec<_>>().join(&b'\n');
                            unwrap!(String::from_utf8(multi_line))
                        } else {
                            unwrap!(std::fs::read_to_string(p))
                        };
                        module_source_code.push_str(&body);

                        let end = format!("\"##\n}}\n");
                        module_source_code.push_str(&end);
                    }
                }
            }
        }
    }
/// read all files and push Rust code into module
/// nested function or inner function, cannot capture environment as closures. Good.
read all files and push Rust code into module
nested function or inner function, cannot capture environment as closures. Good.
read all files and push Rust code into module nested function or inner function cannot capture environment as closures . Good .
fn copy_files_from_dir(root_directory: &str, module_source_code: &mut String) {
        let path = std::path::Path::new(root_directory);
        for entry in unwrap!(path.read_dir()) {
            if let Ok(entry) = entry {
                let p: std::path::PathBuf = entry.path();
                if p.is_file() {
                    let ps = p.to_string_lossy();
                    if !ps.ends_with(".gitignore")
                        && !ps.ends_with("icon-original.png")
                        && !ps.ends_with("README.md")
                        && !ps.ends_with("package.json")
                        && !ps.ends_with("cargo_crev_reviews_wasm_bg.wasm.d.ts")
                        && !ps.ends_with("cargo_crev_reviews_wasm.d.ts")
                        && !ps.ends_with("LICENSE")
                    {
                        let start = format!(
                            "\n\"{}\" => {{\nr##\"",
                            ps.trim_start_matches("web_server_folder")
                        );
                        module_source_code.push_str(&start);
                        // binary files are encoded base64
                        let body = if ps.ends_with(".png") || ps.ends_with(".ico") || ps.ends_with(".woff2") || ps.ends_with(".wasm") {
                            let e = base64::encode(unwrap!(std::fs::read(p)));
                            // it is much easier to have lines of 76 characters in Rust source code.
                            // before decoding base64 I will eliminate \n
                            // Rust string is utf8, but base64 is strictly ascii.
                            // So I have the guarantee 100% that 1 byte = 1 char
                            let multi_line = e.as_bytes().chunks(76).collect::<Vec<_>>().join(&b'\n');
                            unwrap!(String::from_utf8(multi_line))
                        } else {
                            unwrap!(std::fs::read_to_string(p))
                        };
                        module_source_code.push_str(&body);
                        let end = format!("\"##\n}}\n");
                        module_source_code.push_str(&end);
                    }
                }
            }
        }
    }
fn copy_files_from_dir ( root_directory : & str , module_source_code : & mut String ) { let path = std :: path :: Path :: new ( root_directory ) ; for entry in unwrap ! ( path read_dir ( ) ) { if let Ok ( entry ) = entry { let p : std :: path :: PathBuf = entry . path ( ) ; if p . is_file ( ) { let ps = p . to_string_lossy ( ) ; if ! ps . ends_with ( " " ) && ! ps . ends_with ( " " ) && ! ps . ends_with ( " " ) && ! ps . ends_with ( " " ) && ! ps . ends_with ( " " ) && ! ps . ends_with ( " " ) && ! ps . ends_with ( " " ) { let start = format ! ( " \n \" \" \n \" " ps trim_start_matches ( " " ) ) ; module_source_code . push_str ( & start ) ; // binary files are encoded base64 let body = if ps . ends_with ( " " ) || ps . ends_with ( " " ) || ps . ends_with ( " " ) || ps . ends_with ( " " ) { let e = base64 :: encode ( unwrap ! ( std fs read ( p ) ) ) ; // it is much easier to have lines of 76 characters in Rust source code. // before decoding base64 I will eliminate \n // Rust string is utf8, but base64 is strictly ascii. // So I have the guarantee 100% that 1 byte = 1 char let multi_line = e . as_bytes ( ) . chunks ( 76 ) . collect :: < Vec < _ > > ( ) . join ( & b'\n' ) ; unwrap ! ( String from_utf8 ( multi_line ) ) } else { unwrap ! ( std fs read_to_string ( p ) ) } ; module_source_code . push_str ( & body ) ; let end = format ! ( " \" \n \n " ) ; module_source_code . push_str ( & end ) ; } } } } }
read all files and push Rust code into module
nested function or inner function, cannot capture environment as closures.
read all files and push Rust code into module nested function or inner function cannot capture environment as closures .
root_directory
&str
module_source_code
&mut String