add String to Line funcs

This commit is contained in:
askiiart 2025-01-11 14:09:51 -06:00
parent cd41376c22
commit eb67b255f0
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A

View file

@ -84,6 +84,24 @@ pub struct Line {
pub content: String,
}
impl Line {
pub fn from_stdout<S: AsRef<String>>(content: S) -> Self {
return Line {
content: content.as_ref().to_string(),
printed_to: LineType::Stdout,
time: Instant::now(),
};
}
pub fn from_stderr<S: AsRef<String>>(content: S) -> Self {
return Line {
content: content.as_ref().to_string(),
printed_to: LineType::Stderr,
time: Instant::now(),
};
}
}
impl PartialOrd for Line {
fn ge(&self, other: &Line) -> bool {
if self.time >= other.time {