Command trait ref (#364)
This commit is contained in:
parent
9da9c1f5ad
commit
938ec95b40
@ -1,3 +1,7 @@
|
|||||||
|
# master
|
||||||
|
- Added a generic implementation `Command` for `&T: Command`. This allows
|
||||||
|
commands to be queued by reference, as well as by value.
|
||||||
|
|
||||||
# Version 0.14.2
|
# Version 0.14.2
|
||||||
- Fix TIOCGWINSZ for FreeBSD
|
- Fix TIOCGWINSZ for FreeBSD
|
||||||
|
|
||||||
|
@ -39,6 +39,27 @@ pub trait Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Command> Command for &T {
|
||||||
|
type AnsiType = T::AnsiType;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn ansi_code(&self) -> Self::AnsiType {
|
||||||
|
T::ansi_code(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn execute_winapi(&self) -> Result<()> {
|
||||||
|
T::execute_winapi(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
#[inline]
|
||||||
|
fn is_ansi_code_supported(&self) -> bool {
|
||||||
|
T::is_ansi_code_supported(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An interface for commands that can be queued for further execution.
|
/// An interface for commands that can be queued for further execution.
|
||||||
pub trait QueueableCommand<T: Display>: Sized {
|
pub trait QueueableCommand<T: Display>: Sized {
|
||||||
/// Queues the given command for further execution.
|
/// Queues the given command for further execution.
|
||||||
|
Loading…
Reference in New Issue
Block a user