The main enums now have the ability to be displayed.
This commit is contained in:
parent
d69f9b8e9b
commit
82486b1634
@ -38,3 +38,68 @@ pub enum TaskState
|
||||
/// in an inproper state during its lifetime.
|
||||
Unknown
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl TaskState
|
||||
{
|
||||
/// Get a str representation of this variant.
|
||||
pub fn to_str(&self) -> &'static str
|
||||
{
|
||||
match *self
|
||||
{
|
||||
TaskState::Starting =>
|
||||
{
|
||||
"Starting"
|
||||
}
|
||||
|
||||
TaskState::Waiting =>
|
||||
{
|
||||
"Waiting"
|
||||
}
|
||||
|
||||
TaskState::DoneWaiting =>
|
||||
{
|
||||
"DoneWaiting"
|
||||
}
|
||||
|
||||
TaskState::Processing =>
|
||||
{
|
||||
"Processing"
|
||||
}
|
||||
|
||||
TaskState::Finished =>
|
||||
{
|
||||
"Finished"
|
||||
}
|
||||
|
||||
TaskState::Unknown =>
|
||||
{
|
||||
"Unknown"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a String representation of this variant.
|
||||
pub fn to_string(&self) -> String
|
||||
{
|
||||
String::from(self.to_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for TaskState
|
||||
{
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
|
||||
{
|
||||
write!(f, "{}", self.to_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Display for TaskState
|
||||
{
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
|
||||
{
|
||||
write!(f, "{}", self.to_str())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,3 +14,57 @@ pub enum ThreadState
|
||||
///
|
||||
Finished
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl ThreadState
|
||||
{
|
||||
/// Get a str representation of this variant.
|
||||
pub fn to_str(&self) -> &'static str
|
||||
{
|
||||
match *self
|
||||
{
|
||||
ThreadState::Starting =>
|
||||
{
|
||||
"Starting"
|
||||
}
|
||||
|
||||
ThreadState::Idle =>
|
||||
{
|
||||
"Idle"
|
||||
}
|
||||
|
||||
ThreadState::Processing =>
|
||||
{
|
||||
"Processing"
|
||||
}
|
||||
|
||||
ThreadState::Finished =>
|
||||
{
|
||||
"Finished"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a String representation of this variant.
|
||||
pub fn to_string(&self) -> String
|
||||
{
|
||||
String::from(self.to_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for ThreadState
|
||||
{
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
|
||||
{
|
||||
write!(f, "{}", self.to_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Display for ThreadState
|
||||
{
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
|
||||
{
|
||||
write!(f, "{}", self.to_str())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user