Skip to content

Instantly share code, notes, and snippets.

@daboross
Last active August 29, 2015 14:11
Show Gist options
  • Save daboross/0ab4c39544af9f20a114 to your computer and use it in GitHub Desktop.
Save daboross/0ab4c39544af9f20a114 to your computer and use it in GitHub Desktop.
impl LoggerOutput {
pub fn into_logger(self) -> Box<Logger + 'static> {
return box match self {
LoggerOutput::File(path) => WriterLogger::with_file(&path).unwrap(),
LoggerOutput::Stdout => WriterLogger::with_stdout(),
LoggerOutput::Stderr => WriterLogger::with_stderr(),
};
}
}
impl LoggerOutput {
pub fn into_logger<T: Logger>(self) -> T {
return match self {
LoggerOutput::File(path) => WriterLogger::with_file(&path).unwrap(),
LoggerOutput::Stdout => WriterLogger::with_stdout(),
LoggerOutput::Stderr => WriterLogger::with_stderr(),
};
}
}

Error 1:

   Compiling simple-logging v0.0.1 (file:///home/daboross/Projects/Rust/simple-logging)
/home/daboross/Projects/Rust/simple-logging/src/config.rs:27:20: 31:10 error: match arms have incompatible types: expected `config::WriterLogger<std::io::fs::File>`, found `config::WriterLogger<std::io::buffered::LineBufferedWriter<std::io::stdio::StdWriter>>` (expected struct std::io::fs::File, found struct std::io::buffered::LineBufferedWriter)
/home/daboross/Projects/Rust/simple-logging/src/config.rs:27         return box match self {
/home/daboross/Projects/Rust/simple-logging/src/config.rs:28             LoggerOutput::File(path) => WriterLogger::with_file(&path).unwrap(),
/home/daboross/Projects/Rust/simple-logging/src/config.rs:29             LoggerOutput::Stdout => WriterLogger::with_stdout(),
/home/daboross/Projects/Rust/simple-logging/src/config.rs:30             LoggerOutput::Stderr => WriterLogger::with_stderr(),
/home/daboross/Projects/Rust/simple-logging/src/config.rs:31         };
/home/daboross/Projects/Rust/simple-logging/src/config.rs:29:37: 29:64 note: match arm with an incompatible type
/home/daboross/Projects/Rust/simple-logging/src/config.rs:29             LoggerOutput::Stdout => WriterLogger::with_stdout(),
                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `simple-logging`.

To learn more, run the command again with --verbose.
[Finished in 0.3s with exit code 101]
[cmd: ['cargo', 'build']]
[dir: /home/daboross/Projects/Rust/simple-logging/src]
[path: /home/daboross/.local/opt/apache-maven-3.2.3/bin:/home/daboross/.local/bin:/home/daboross/.bin/aliases:/home/daboross/.bin/compiled:/home/daboross/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]

Error 2:

   Compiling simple-logging v0.0.1 (file:///home/daboross/Projects/Rust/simple-logging)
/home/daboross/Projects/Rust/simple-logging/src/config.rs:27:16: 31:10 error: match arms have incompatible types: expected `config::WriterLogger<std::io::fs::File>`, found `config::WriterLogger<std::io::buffered::LineBufferedWriter<std::io::stdio::StdWriter>>` (expected struct std::io::fs::File, found struct std::io::buffered::LineBufferedWriter)
/home/daboross/Projects/Rust/simple-logging/src/config.rs:27         return match self {
/home/daboross/Projects/Rust/simple-logging/src/config.rs:28             LoggerOutput::File(path) => WriterLogger::with_file(&path).unwrap(),
/home/daboross/Projects/Rust/simple-logging/src/config.rs:29             LoggerOutput::Stdout => WriterLogger::with_stdout(),
/home/daboross/Projects/Rust/simple-logging/src/config.rs:30             LoggerOutput::Stderr => WriterLogger::with_stderr(),
/home/daboross/Projects/Rust/simple-logging/src/config.rs:31         };
/home/daboross/Projects/Rust/simple-logging/src/config.rs:29:37: 29:64 note: match arm with an incompatible type
/home/daboross/Projects/Rust/simple-logging/src/config.rs:29             LoggerOutput::Stdout => WriterLogger::with_stdout(),
                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `simple-logging`.

To learn more, run the command again with --verbose.
[Finished in 0.3s with exit code 101]
[cmd: ['cargo', 'build']]
[dir: /home/daboross/Projects/Rust/simple-logging/src]
[path: /home/daboross/.local/opt/apache-maven-3.2.3/bin:/home/daboross/.local/bin:/home/daboross/.bin/aliases:/home/daboross/.bin/compiled:/home/daboross/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment