Commit 657af15e authored by Alexis Janon's avatar Alexis Janon
Browse files

Added 'dyn' keyword to trait objects as per 2113

parent ffc792e1
Pipeline #4089 passed with stage
in 2 minutes and 25 seconds
......@@ -33,7 +33,7 @@ pub struct Arguments {
// TODO: remove all these clone()!
impl InCommand {
fn to_create_slice(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
fn to_create_slice(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
match self.name {
Some(ref name) => match self.properties {
Some(ref properties) => Ok(Box::new(CommandList::new(vec![
......@@ -58,7 +58,7 @@ impl InCommand {
}
}
fn to_modify_slice(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
fn to_modify_slice(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
match self.name {
Some(ref name) => match self.properties {
Some(ref properties) => Ok(Box::new(ModifySlice::new(
......@@ -72,7 +72,7 @@ impl InCommand {
}
}
fn to_remove_slice(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
fn to_remove_slice(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
match self.name {
Some(ref name) => Ok(Box::new(RemoveSlice::new(
name.clone(),
......@@ -82,7 +82,7 @@ impl InCommand {
}
}
fn to_exec(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
fn to_exec(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
match self.name {
Some(ref name) => match self.cmd {
Some(ref cmd) => Ok(Box::new(Exec::new(
......@@ -98,7 +98,7 @@ impl InCommand {
}
}
fn to_fork_exec(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
fn to_fork_exec(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
match self.name {
Some(ref name) => match self.cmd {
Some(ref cmd) => Ok(Box::new(ForkExec::new(
......@@ -114,7 +114,7 @@ impl InCommand {
}
}
fn to_spawn(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
fn to_spawn(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
let name = match self.name {
Some(ref name) => name.clone(),
None => random_string(RANDOM_NAME_SIZE),
......@@ -133,7 +133,7 @@ impl InCommand {
}
}
pub fn to_command(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<Command>> {
pub fn to_command(&self, controllers: Rc<SysFsControllerList>) -> Result<Box<dyn Command>> {
match self.command.to_lowercase().as_str() {
"create" => self.to_create_slice(controllers),
"remove" => self.to_remove_slice(controllers),
......@@ -165,7 +165,7 @@ impl Arguments {
self.commands
.iter()
.map(|c| c.to_command(Rc::clone(&controllers)))
.collect::<Result<Vec<Box<Command>>>>()?,
.collect::<Result<Vec<Box<dyn Command>>>>()?,
))
}
}
......
use transaction::*;
pub struct CommandList {
subcommands: Vec<Box<Command>>,
subcommands: Vec<Box<dyn Command>>,
current: Option<usize>,
}
impl CommandList {
pub fn new(subcommands: Vec<Box<Command>>) -> Self {
pub fn new(subcommands: Vec<Box<dyn Command>>) -> Self {
CommandList {
subcommands,
current: None,
......
......@@ -41,7 +41,7 @@ impl CreateSlice {
.map(|path| path.join(&name))
.map(|path| CreateDir::new(path, Rc::clone(&controllers)))
.map(Box::new)
.map(|b| b as Box<Command>)
.map(|b| b as Box<dyn Command>)
.collect();
CreateSlice {
name: name,
......
......@@ -35,7 +35,7 @@ impl Exec {
.map(|path| {
GetSetValue::new(path.to_path_buf(), "0".to_owned(), Rc::clone(&controllers))
}).map(Box::new)
.map(|b| b as Box<Command>)
.map(|b| b as Box<dyn Command>)
.collect::<Vec<_>>();
let mut process_cmd = process::Command::new(cmd);
let mut full_cmd = cmd.to_owned();
......
......@@ -27,7 +27,7 @@ impl ModifySlice {
Rc::clone(&controllers),
)
}).map(Box::new)
.map(|b| b as Box<Command>)
.map(|b| b as Box<dyn Command>)
.collect();
ModifySlice {
name: name,
......
......@@ -18,7 +18,7 @@ impl RemoveSlice {
.map(|path| path.join(&name))
.map(|path| RemoveDir::new(path, Rc::clone(&controllers)))
.map(Box::new)
.map(|b| b as Box<Command>)
.map(|b| b as Box<dyn Command>)
.collect();
RemoveSlice {
name: name,
......
......@@ -24,7 +24,7 @@ impl Spawn {
name.clone(),
args,
Rc::clone(&controllers),
)) as Box<Command>];
)) as Box<dyn Command>];
if let Some(properties) = properties {
commands.push(Box::new(ModifySlice::new(
name.clone(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment