fn main() {
let output = Command::new("/bin/bash")
.args(&["-c", "docker","build", "-t", "postgres:latest", "-", "<>", "dockers/PostgreSql"])
.output()
.expect("failed to execute process");
println!("{:?}", output);
}
Run Code Online (Sandbox Code Playgroud)
const fn get_dockerfile() -> String {
let mut file_content = String::new();
let mut file = File::open("dockers/PostgreSql").expect("Failed to read the file");
file.read_to_string(&mut file_content);
file_content
}
const DOCKERFILE: String = get_dockerfile();
Run Code Online (Sandbox Code Playgroud)
我正在编写一个 Rust 脚本来管理 docker 操作。
const
变量我可以实现这一点,但我收到此错误:error[E0723]: mutable references in const fn are unstable
--> src/main.rs:9:5
|
9 | file.read_to_string(&mut file_content);
Run Code Online (Sandbox Code Playgroud) rust ×2