Skip to content

Instantly share code, notes, and snippets.

@tormol
Created June 26, 2017 17:05
Show Gist options
  • Save tormol/98dbd2b6bfd50985be9a4aa889eaa74d to your computer and use it in GitHub Desktop.
Save tormol/98dbd2b6bfd50985be9a4aa889eaa74d to your computer and use it in GitHub Desktop.
Removes encode_unicode as a dependency of rustyline
commit 16e951e0e7275500d2d27c9431a7a9d6e41b6ad9
Author: Torbjørn Birch Moltu <t.b.moltu@lyse.net>
Date: Tue Jun 20 16:50:30 2017 +0200
Remove encode_unicode dependency
This bumps the minimum version of Rust from 1.12 to 1.15
and is therefore a breaking change.
diff --git a/.travis.yml b/.travis.yml
index 76221a4..80745d1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: rust
rust:
- - 1.12.0
+ - 1.15.1
- beta
- nightly
script:
diff --git a/Cargo.toml b/Cargo.toml
index 278b223..76fa9fe 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,6 @@ license = "MIT"
[dependencies]
libc = "0.2.7"
unicode-width = "0.1.3"
-encode_unicode = "0.1.3"
[target.'cfg(unix)'.dependencies]
nix = "0.7"
diff --git a/src/lib.rs b/src/lib.rs
index 8143fc2..788b0b6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -20,7 +20,6 @@ extern crate libc;
#[cfg(unix)]
extern crate nix;
extern crate unicode_width;
-extern crate encode_unicode;
#[cfg(windows)]
extern crate winapi;
#[cfg(windows)]
@@ -45,7 +44,6 @@ use std::path::Path;
use std::result;
use tty::{RawMode, RawReader, Terminal, Term};
-use encode_unicode::CharExt;
use completion::{Completer, longest_common_prefix};
use consts::KeyPress;
use history::{Direction, History};
@@ -297,7 +295,8 @@ fn edit_insert(s: &mut State, ch: char) -> Result<()> {
// Avoid a full update of the line in the trivial case.
let cursor = calculate_position(&s.line[..s.line.pos()], s.prompt_size, s.cols);
s.cursor = cursor;
- write_and_flush(s.out, ch.to_utf8().as_bytes())
+ let mut buf = [0u8; 4];
+ write_and_flush(s.out, ch.encode_utf8(&mut buf).as_bytes())
} else {
s.refresh_line()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment