Coding style

This commit is contained in:
Adrian Heine 2019-03-01 18:47:47 +01:00
parent cbb5742ac3
commit abb6947853
33 changed files with 79 additions and 151 deletions

View file

@ -16,14 +16,14 @@ pub enum UserAdderError {
impl Error for UserAdderError {
fn description(&self) -> &str {
match self {
&UserAdderError::AlreadyExists => "User already exists",
&UserAdderError::UnknownError => "Unknown error",
&UserAdderError::ImplError(_) => "User adding error"
UserAdderError::AlreadyExists => "User already exists",
UserAdderError::UnknownError => "Unknown error",
UserAdderError::ImplError(_) => "User adding error"
}
}
fn cause(&self) -> Option<&Error> {
match self {
&UserAdderError::ImplError(ref e) => Some(e.as_ref()),
UserAdderError::ImplError(ref e) => Some(e.as_ref()),
_ => None
}
}
@ -50,7 +50,7 @@ pub enum UserError {
impl Error for UserError {
fn description(&self) -> &str {
match self {
&UserError::GenericError => "Could not find out if user exists"
UserError::GenericError => "Could not find out if user exists"
}
}
fn cause(&self) -> Option<&Error> {
@ -77,11 +77,7 @@ pub struct User<'a, C: 'a + CommandRunner, A: 'a + UserAdder> {
impl<'a, C: CommandRunner, A: 'a + UserAdder> User<'a, C, A> {
pub fn new(user_name: Cow<'a, str>, command_runner: &'a C, user_adder: &'a A) -> Self {
User {
user_name: user_name,
command_runner: command_runner,
user_adder: user_adder
}
User { user_name, command_runner, user_adder }
}
}
@ -124,7 +120,7 @@ pub struct SystemUserAdder<'a, C: 'a + CommandRunner> {
impl<'a, C: CommandRunner> SystemUserAdder<'a, C> {
pub fn new(command_runner: &'a C) -> Self {
SystemUserAdder { command_runner: command_runner }
SystemUserAdder { command_runner }
}
}