From 67fe54119bd8783eee91143b326bd3ba571bfffb Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 18 Jan 2020 13:49:20 +0800 Subject: [PATCH 1/3] Avoid allocating temporary Strings in Display implementations --- src/cursor.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index bbc0394..939529b 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -50,7 +50,7 @@ impl Default for Goto { impl fmt::Display for Goto { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { debug_assert!(self != &Goto(0, 0), "Goto is one-based."); - f.write_str(&String::from(*self)) + write!(f, "\x1B[{};{}H", self.1, self.0) } } @@ -67,7 +67,7 @@ impl From for String { impl fmt::Display for Left { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&String::from(*self)) + write!(f, "\x1B[{}D", self.0) } } @@ -84,7 +84,7 @@ impl From for String { impl fmt::Display for Right { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&String::from(*self)) + write!(f, "\x1B[{}C", self.0) } } @@ -101,7 +101,7 @@ impl From for String { impl fmt::Display for Up { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&String::from(*self)) + write!(f, "\x1B[{}A", self.0) } } @@ -118,7 +118,7 @@ impl From for String { impl fmt::Display for Down { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&String::from(*self)) + write!(f, "\x1B[{}B", self.0) } } From e5e592b5591f0a67a7fc7d31cc8a3cc90baa22f8 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 18 Jan 2020 14:46:37 +0800 Subject: [PATCH 2/3] fix gitlab pipeline --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cda5aa6..272b863 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,7 @@ cache: build:linux:stable: stage: build script: + - rustup update stable - cargo +stable build --verbose build:linux: From f3bd2366ee49fb6a36ec40fa1fee7d685c3d8dda Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 18 Jan 2020 14:58:07 +0800 Subject: [PATCH 3/3] gitlab pipeline: try to run inside "script" to get a tty --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 272b863..4fe13dd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,13 +28,13 @@ test:linux:stable: - build:linux:stable script: - rustup update stable - - cargo +stable test --verbose + - script -c "cargo +stable test --verbose" test:linux: stage: test dependencies: - build:linux - script: cargo +nightly test --verbose + script: script -c "cargo +nightly test --verbose" test:redox: stage: test