INNER CODE UNIT · Rust
save_runtime
vmware-labs/wasm-workers-server · crates/config/src/lib.rs:54
pub fn save_runtime(&mut self, repo_name: &str, repo_url: &str, runtime: &Runtime) {
let repo = self.repositories.iter_mut().find(|r| r.name == repo_name);
// Shadow to init an empty one if required
match repo {
Some(r) => r.runtimes.push(runtime.clone()),
None => {
let new_repo = ConfigRepository {
name: repo_name.to_string(),
url: repo_url.to_string(),
runtimes: vec![runtime.clone()],
};
self.repositories.push(new_repo);
}
};
}