From ad9146075b32915f6738e790ebd7f02016da6bc9 Mon Sep 17 00:00:00 2001 From: Frank Zechert Date: Sat, 1 Apr 2023 04:33:45 +0200 Subject: [PATCH] implements From for String --- src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a1638c6..f7ecb3f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,14 +29,14 @@ //! //! ``` //! use ansi::c0::BEL; -//! print!("{}", BEL); +//! println!("Let's ring the bell {}", BEL); //! ``` //! //! Or to move the cursor to line 5, column 13: //! //! ``` //! use ansi::control_sequences::CUP; -//! print!("{}", CUP(Some(5), Some(13))); +//! print!("{}", CUP(5.into(), 13.into())); //! ``` //! //! It might be necessary in some circumstances to announce the active set of control sequences before they can be used. @@ -265,6 +265,12 @@ impl fmt::Debug for ControlFunction { } } +impl From for String { + fn from(control_function: ControlFunction) -> Self { + format!("{}", control_function) + } +} + pub mod c0; pub mod c1; pub mod control_sequences;