use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Stream {
StandardError,
StandardOutput,
}
impl Display for Stream {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result {
match self {
Self::StandardError => formatter.write_str("standard error"),
Self::StandardOutput => formatter.write_str("standard output"),
}
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::missing_panics_doc)]
use super::*;
#[test]
fn stream_is_send_and_sync() {
fn assert_send_and_sync<T: Send + Sync>() {}
assert_send_and_sync::<Stream>();
}
#[test]
fn to_string_of_the_standard_error_names_the_stream() {
let stream = Stream::StandardError;
assert_eq!(stream.to_string(), "standard error");
}
#[test]
fn to_string_of_the_standard_output_names_the_stream() {
let stream = Stream::StandardOutput;
assert_eq!(stream.to_string(), "standard output");
}
}