Moved Ropey dependency in-tree.

This commit is contained in:
Nathan Vegdahl 2017-11-25 23:12:37 -08:00
parent 45e6125bbc
commit 8d146a595e
7 changed files with 4220 additions and 71 deletions

257
Cargo.lock generated
View File

@ -1,22 +1,22 @@
[root] [[package]]
name = "Led" name = "Led"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"ropey 0.3.0 (git+https://github.com/cessen/ropey.git)", "ropey 0.3.0",
"rustbox 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustbox 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.5.1" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -24,19 +24,25 @@ name = "bitflags"
version = "0.2.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bitflags"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "docopt" name = "docopt"
version = "0.6.78" version = "0.6.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "encoding" name = "encoding"
version = "0.2.32" version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", "encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -91,24 +97,45 @@ name = "encoding_index_tests"
version = "0.1.4" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fuchsia-zircon"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "gag" name = "gag"
version = "0.1.9" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "kernel32-sys" name = "kernel32-sys"
version = "0.2.1" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "lazy_static"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.1.12" version = "0.1.12"
@ -116,56 +143,119 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.7" version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "0.1.10" version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "num" name = "num"
version = "0.1.31" version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "num-complex 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "num-bigint"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-complex"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-integer"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-iter"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-rational"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.3.14" version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "redox_syscall"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "regex" name = "regex"
version = "0.1.55" version = "0.1.80"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.2.5" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "ropey" name = "ropey"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/cessen/ropey.git#aa4dcf8d39d77f295126eed77d56f4b93a069b49"
dependencies = [ dependencies = [
"unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -176,58 +266,62 @@ dependencies = [
"bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gag 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "gag 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"termbox-sys 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "termbox-sys 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "rustc-serialize" name = "rustc-serialize"
version = "0.3.18" version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.3.0" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "2.1.1" version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "termbox-sys" name = "termbox-sys"
version = "0.2.9" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "thread-id"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "thread_local"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "0.1.2" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -237,7 +331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.5" version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -245,3 +339,46 @@ name = "winapi-build"
version = "0.1.1" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
"checksum bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a41f80ec2e140d19e789764fdf22d0f2da98fe7e55d26f99db59cb3d2605d327"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9"
"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
"checksum encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7"
"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
"checksum gag 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c606f5c0da18075916377e73de8aec7c140e1b6110a3cf26ae1f47873529b47e"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e32a70cf75e5846d53a673923498228bbec6a8624708a9ea5645f075d6276122"
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
"checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525"
"checksum num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "8fd0f8dbb4c0960998958a796281d88c16fbe68d87b1baa6f31e2979e81fd0bd"
"checksum num-complex 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "503e668405c5492d67cf662a81e05be40efe2e6bcf10f7794a07bd9865e704e6"
"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01"
"checksum num-rational 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "0c7cb72a95250d8a370105c828f388932373e0e94414919891a0f945222310fe"
"checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0"
"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd"
"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
"checksum rustbox 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "67db7a8f30d0cadb67687a8c25ee32aaa57bf9d6497fd0fc92584b267bad975a"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c"
"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0"
"checksum termbox-sys 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "e32daa27881ea4b2ef36e4972d6cdefb241c19ac48d318381b688d1a631b8760"
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"

View File

@ -1,26 +1,25 @@
[package] [workspace]
members = [
"sub_crates/ropey"
]
[package]
name = "Led" name = "Led"
version = "0.0.1" version = "0.0.1"
authors = ["Nathan Vegdahl <cessen@cessen.com>"] authors = ["Nathan Vegdahl <cessen@cessen.com>"]
license = "MIT"
[[bin]] [[bin]]
name = "led" name = "led"
path = "src/main.rs" path = "src/main.rs"
[dependencies.ropey]
git = "https://github.com/cessen/ropey.git"
#[dependencies.sdl2]
#git = "https://github.com/AngryLawyer/rust-sdl2.git"
#[dependencies.freetype-rs]
#git = "https://github.com/PistonDevelopers/freetype-rs.git"
[dependencies] [dependencies]
rustc-serialize = "0.3.0" rustc-serialize = "0.3.0"
unicode-segmentation = "0.1" unicode-segmentation = "1.2"
unicode-width = "0.1" unicode-width = "0.1"
docopt = "0.6" docopt = "0.6"
encoding = "0.2" encoding = "0.2"
rustbox = "0.8" rustbox = "0.8"
[dependencies.ropey]
path = "sub_crates/ropey"

View File

@ -0,0 +1,8 @@
[package]
name = "ropey"
version = "0.3.0"
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
license = "MIT"
[dependencies]
unicode-segmentation = "1.2"

View File

@ -0,0 +1,266 @@
#![cfg(test)]
/*
use super::*;
use test::Bencher;
#[bench]
fn new_from_str_1(b: &mut Bencher) {
b.iter(|| {
let _ = Rope::from_str("
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
});
}
#[bench]
fn new_from_str_2(b: &mut Bencher) {
b.iter(|| {
let _ = Rope::from_str("
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
});
}
#[bench]
fn new_from_str_3(b: &mut Bencher) {
b.iter(|| {
let _ = Rope::from_str("
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
});
}
#[bench]
fn insert_text_bench_1(b: &mut Bencher) {
b.iter(|| {
let mut rope = Rope::new();
for _ in 0..200 {
rope.insert_text_at_char_index("Hi", 0);
}
});
}
#[bench]
fn insert_text_bench_2(b: &mut Bencher) {
b.iter(|| {
let mut rope = Rope::new();
for i in 0..200 {
rope.insert_text_at_char_index("Hi", i/2);
}
});
}
#[bench]
fn insert_text_bench_3(b: &mut Bencher) {
b.iter(|| {
let mut rope = Rope::new();
for i in 0..200 {
rope.insert_text_at_char_index("Hi", i);
}
});
}
#[bench]
fn insert_large_text_bench_1(b: &mut Bencher) {
let s = String::from_utf8(vec!['c' as u8; 3457]).unwrap();
b.iter(|| {
let mut rope = Rope::from_str("Hello there!");
rope.insert_text_at_char_index(&s[..], 0);
});
}
#[bench]
fn insert_large_text_bench_2(b: &mut Bencher) {
let s = String::from_utf8(vec!['c' as u8; 3457]).unwrap();
b.iter(|| {
let mut rope = Rope::from_str("Hello there!");
rope.insert_text_at_char_index(&s[..], 3);
});
}
#[bench]
fn insert_large_text_bench_3(b: &mut Bencher) {
let s = String::from_utf8(vec!['c' as u8; 3457]).unwrap();
b.iter(|| {
let mut rope = Rope::from_str("Hello there!");
rope.insert_text_at_char_index(&s[..], 12);
});
}
#[bench]
fn remove_text_bench_1(b: &mut Bencher) {
b.iter(|| {
let mut rope = Rope::from_str("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
for _ in 0..200 {
rope.remove_text_between_char_indices(0, 2);
}
});
}
#[bench]
fn remove_text_bench_2(b: &mut Bencher) {
b.iter(|| {
let mut rope = Rope::from_str("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
for i in 0..200 {
rope.remove_text_between_char_indices((200-i)-1, (200-i)+1);
}
});
}
#[bench]
fn remove_text_bench_3(b: &mut Bencher) {
b.iter(|| {
let mut rope = Rope::from_str("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
for i in 0..200 {
rope.remove_text_between_char_indices(400-(i*2)-2, 400-(i*2));
}
});
}
#[bench]
fn append_1(b: &mut Bencher) {
b.iter(|| {
let mut left = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 3617]).unwrap())[..]);
let right = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 3617]).unwrap())[..]);
left.append(right);
});
}
#[bench]
fn append_2(b: &mut Bencher) {
b.iter(|| {
let mut left = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 263]).unwrap())[..]);
let right = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 3617]).unwrap())[..]);
left.append(right);
});
}
#[bench]
fn append_3(b: &mut Bencher) {
b.iter(|| {
let mut left = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 3617]).unwrap())[..]);
let right = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 263]).unwrap())[..]);
left.append(right);
});
}
#[bench]
fn split_at_char_index_1(b: &mut Bencher) {
b.iter(|| {
let mut left = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 7649]).unwrap())[..]);
let _ = left.split_at_char_index(3617);
});
}
#[bench]
fn split_at_char_index_2(b: &mut Bencher) {
b.iter(|| {
let mut left = Rope::from_str(&(String::from_utf8(vec!['c' as u8; 7649]).unwrap())[..]);
let _ = left.split_at_char_index(263);
});
}
*/

1486
sub_crates/ropey/src/lib.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,481 @@
#![allow(dead_code)]
//! Misc helpful utility functions for TextBuffer related stuff.
use std::str::CharIndices;
use std::iter::repeat;
use unicode_segmentation::UnicodeSegmentation;
pub fn is_line_ending(text: &str) -> bool {
match text {
"\u{000D}\u{000A}"
| "\u{000A}"
| "\u{000B}"
| "\u{000C}"
| "\u{000D}"
| "\u{0085}"
| "\u{2028}"
| "\u{2029}" => true,
_ => false
}
}
pub fn line_ending_count(text: &str) -> usize {
let mut count = 0;
for g in UnicodeSegmentation::graphemes(text, true) {
if is_line_ending(g) {
count += 1;
}
}
return count;
}
pub fn char_count(text: &str) -> usize {
let mut count = 0;
for _ in text.chars() {
count += 1;
}
return count;
}
pub fn grapheme_count(text: &str) -> usize {
let mut count = 0;
for _ in UnicodeSegmentation::graphemes(text, true) {
count += 1;
}
return count;
}
pub fn grapheme_count_is_less_than(text: &str, n: usize) -> bool {
let mut count = 0;
for _ in UnicodeSegmentation::graphemes(text, true) {
count += 1;
if count >= n {
return false;
}
}
return true;
}
pub fn char_grapheme_line_ending_count(text: &str) -> (usize, usize, usize) {
let mut cc = 0;
let mut gc = 0;
let mut lec = 0;
for g in UnicodeSegmentation::graphemes(text, true) {
cc += char_count(g);
gc += 1;
if is_line_ending(g) {
lec += 1;
}
}
return (cc, gc, lec);
}
pub fn graphemes_are_mergeable(s1: &str, s2: &str) -> bool {
let mut s = String::with_capacity(s1.len() + s2.len());
s.push_str(s1);
s.push_str(s2);
return grapheme_count(&s[..]) == 1;
}
pub fn char_pos_to_byte_pos(text: &str, pos: usize) -> usize {
let mut i: usize = 0;
for (offset, _) in text.char_indices() {
if i == pos {
return offset;
}
i += 1;
}
if i == pos {
return text.len();
}
panic!("char_pos_to_byte_pos(): char position off the end of the string.");
}
pub fn grapheme_pos_to_byte_pos(text: &str, pos: usize) -> usize {
let mut i: usize = 0;
for (offset, _) in UnicodeSegmentation::grapheme_indices(text, true) {
if i == pos {
return offset;
}
i += 1;
}
if i == pos {
return text.len();
}
panic!("grapheme_pos_to_byte_pos(): grapheme position off the end of the string.");
}
pub fn char_pos_to_grapheme_pos(text: &str, pos: usize) -> usize {
let mut i = 0usize;
let mut cc = 0usize;
for g in UnicodeSegmentation::graphemes(text, true) {
if cc == pos {
return i;
}
cc += char_count(g);
if cc > pos {
return i;
}
i += 1;
}
if cc == pos {
return i;
}
panic!("char_pos_to_grapheme_pos(): char position off the end of the string.");
}
pub fn grapheme_pos_to_char_pos(text: &str, pos: usize) -> usize {
let mut i = 0usize;
let mut cc = 0usize;
for g in UnicodeSegmentation::graphemes(text, true) {
if i == pos {
return cc;
}
cc += char_count(g);
i += 1;
}
if i == pos {
return cc;
}
panic!("grapheme_pos_to_char_pos(): grapheme position off the end of the string.");
}
/// Inserts the given text into the given string at the given grapheme index.
pub fn insert_text_at_char_index(s: &mut String, text: &str, pos: usize) {
// Find insertion position in bytes
let byte_pos = char_pos_to_byte_pos(&s[..], pos);
// Get byte vec of string
let byte_vec = unsafe { s.as_mut_vec() };
// Grow data size
byte_vec.extend(repeat(0).take(text.len()));
// Move old bytes forward
// TODO: use copy_memory()...?
let mut from = byte_vec.len() - text.len();
let mut to = byte_vec.len();
while from > byte_pos {
from -= 1;
to -= 1;
byte_vec[to] = byte_vec[from];
}
// Copy new bytes in
// TODO: use copy_memory()
let mut i = byte_pos;
for b in text.bytes() {
byte_vec[i] = b;
i += 1
}
}
/// Inserts the given text into the given string at the given grapheme index.
pub fn insert_text_at_grapheme_index(s: &mut String, text: &str, pos: usize) {
// Find insertion position in bytes
let byte_pos = grapheme_pos_to_byte_pos(&s[..], pos);
// Get byte vec of string
let byte_vec = unsafe { s.as_mut_vec() };
// Grow data size
byte_vec.extend(repeat(0).take(text.len()));
// Move old bytes forward
// TODO: use copy_memory()...?
let mut from = byte_vec.len() - text.len();
let mut to = byte_vec.len();
while from > byte_pos {
from -= 1;
to -= 1;
byte_vec[to] = byte_vec[from];
}
// Copy new bytes in
// TODO: use copy_memory()
let mut i = byte_pos;
for g in UnicodeSegmentation::graphemes(text, true) {
for b in g.bytes() {
byte_vec[i] = b;
i += 1
}
}
}
/// Removes the text between the given char indices in the given string.
pub fn remove_text_between_char_indices(s: &mut String, pos_a: usize, pos_b: usize) {
// Bounds checks
assert!(pos_a <= pos_b, "remove_text_between_char_indices(): pos_a must be less than or equal to pos_b.");
if pos_a == pos_b {
return;
}
// Find removal positions in bytes
// TODO: get both of these in a single pass
let byte_pos_a = char_pos_to_byte_pos(&s[..], pos_a);
let byte_pos_b = char_pos_to_byte_pos(&s[..], pos_b);
// Get byte vec of string
let byte_vec = unsafe { s.as_mut_vec() };
// Move bytes to fill in the gap left by the removed bytes
let mut from = byte_pos_b;
let mut to = byte_pos_a;
while from < byte_vec.len() {
byte_vec[to] = byte_vec[from];
from += 1;
to += 1;
}
// Remove data from the end
let final_text_size = byte_vec.len() + byte_pos_a - byte_pos_b;
byte_vec.truncate(final_text_size);
}
/// Removes the text between the given grapheme indices in the given string.
pub fn remove_text_between_grapheme_indices(s: &mut String, pos_a: usize, pos_b: usize) {
// Bounds checks
assert!(pos_a <= pos_b, "remove_text_between_grapheme_indices(): pos_a must be less than or equal to pos_b.");
if pos_a == pos_b {
return;
}
// Find removal positions in bytes
// TODO: get both of these in a single pass
let byte_pos_a = grapheme_pos_to_byte_pos(&s[..], pos_a);
let byte_pos_b = grapheme_pos_to_byte_pos(&s[..], pos_b);
// Get byte vec of string
let byte_vec = unsafe { s.as_mut_vec() };
// Move bytes to fill in the gap left by the removed bytes
let mut from = byte_pos_b;
let mut to = byte_pos_a;
while from < byte_vec.len() {
byte_vec[to] = byte_vec[from];
from += 1;
to += 1;
}
// Remove data from the end
let final_text_size = byte_vec.len() + byte_pos_a - byte_pos_b;
byte_vec.truncate(final_text_size);
}
/// Splits a string into two strings at the char index given.
/// The first section of the split is stored in the original string,
/// while the second section of the split is returned as a new string.
pub fn split_string_at_char_index(s1: &mut String, pos: usize) -> String {
let mut s2 = String::new();
// Code block to contain the borrow of s2
{
let byte_pos = char_pos_to_byte_pos(&s1[..], pos);
let byte_vec_1 = unsafe { s1.as_mut_vec() };
let byte_vec_2 = unsafe { s2.as_mut_vec() };
byte_vec_2.extend((&byte_vec_1[byte_pos..]).iter().map(|&i| i));
byte_vec_1.truncate(byte_pos);
}
return s2;
}
/// Splits a string into two strings at the grapheme index given.
/// The first section of the split is stored in the original string,
/// while the second section of the split is returned as a new string.
pub fn split_string_at_grapheme_index(s1: &mut String, pos: usize) -> String {
let mut s2 = String::new();
// Code block to contain the borrow of s2
{
let byte_pos = grapheme_pos_to_byte_pos(&s1[..], pos);
let byte_vec_1 = unsafe { s1.as_mut_vec() };
let byte_vec_2 = unsafe { s2.as_mut_vec() };
byte_vec_2.extend((&byte_vec_1[byte_pos..]).iter().map(|&i| i));
byte_vec_1.truncate(byte_pos);
}
return s2;
}
/// A grapheme iterator that only recognizes CRLF as a composite grapheme.
/// This is only temporary, a stand-in for the proper Graphemes iterator
/// from stdlib which is currently marked unstable and thus is unavailable
/// in stable Rust builds. When Graphemes makes its way back into stdlib
/// or is split into another library, replace this with it.
pub struct TempGraphemeIndices<'a> {
s: &'a str,
chars: CharIndices<'a>,
i1: usize,
i2: usize,
}
impl<'a> TempGraphemeIndices<'a> {
fn push_i2(&mut self) {
if let Some((i, _)) = self.chars.next() {
self.i2 = i;
}
else {
self.i2 = self.s.len();
}
}
}
impl<'a> Iterator for TempGraphemeIndices<'a> {
type Item = (usize, &'a str);
fn next(&mut self) -> Option<(usize, &'a str)> {
// Advance the iterator
if self.i1 == self.i2 {
self.push_i2();
}
// If we're at the end, we're done
if self.i1 == self.s.len() {
return None;
}
match &(self.s)[self.i1 .. self.i2] {
"\u{000D}" => {
let ii = self.i1;
let i3 = self.i2;
self.push_i2();
if &(self.s)[self.i1 .. self.i2] == "\u{000D}\u{000A}" {
let s = &(self.s)[self.i1 .. self.i2];
self.i1 = self.i2;
return Some((ii, s));
}
else {
let ii = self.i1;
let s = &(self.s)[self.i1 .. i3];
self.i1 = i3;
return Some((ii, s));
}
},
_ => {
let ii = self.i1;
let s = &(self.s)[self.i1 .. self.i2];
self.i1 = self.i2;
return Some((ii, s));
},
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn graphemes_are_mergeable_1() {
assert!(graphemes_are_mergeable("\u{000D}", "\u{000A}"));
assert!(!graphemes_are_mergeable("\u{000A}", "\u{000D}"));
assert!(!graphemes_are_mergeable("a", "b"));
}
#[test]
fn char_pos_to_grapheme_pos_1() {
let s = "Hello\u{000D}\u{000A}there!";
assert_eq!(char_pos_to_grapheme_pos(s, 0), 0);
assert_eq!(char_pos_to_grapheme_pos(s, 5), 5);
assert_eq!(char_pos_to_grapheme_pos(s, 6), 5);
assert_eq!(char_pos_to_grapheme_pos(s, 7), 6);
assert_eq!(char_pos_to_grapheme_pos(s, 13), 12);
}
#[test]
fn char_pos_to_grapheme_pos_2() {
let s = "a";
assert_eq!(char_pos_to_grapheme_pos(s, 0), 0);
assert_eq!(char_pos_to_grapheme_pos(s, 1), 1);
}
#[test]
fn char_pos_to_grapheme_pos_3() {
let s = "\u{000D}\u{000A}";
assert_eq!(char_pos_to_grapheme_pos(s, 0), 0);
assert_eq!(char_pos_to_grapheme_pos(s, 1), 0);
assert_eq!(char_pos_to_grapheme_pos(s, 2), 1);
}
#[test]
fn char_pos_to_grapheme_pos_4() {
let s = "";
assert_eq!(char_pos_to_grapheme_pos(s, 0), 0);
}
#[test]
fn grapheme_pos_to_char_pos_1() {
let s = "Hello\u{000D}\u{000A}there!";
assert_eq!(grapheme_pos_to_char_pos(s, 0), 0);
assert_eq!(grapheme_pos_to_char_pos(s, 5), 5);
assert_eq!(grapheme_pos_to_char_pos(s, 6), 7);
assert_eq!(grapheme_pos_to_char_pos(s, 8), 9);
assert_eq!(grapheme_pos_to_char_pos(s, 12), 13);
}
#[test]
fn grapheme_pos_to_char_pos_2() {
let s = "a";
assert_eq!(grapheme_pos_to_char_pos(s, 0), 0);
assert_eq!(grapheme_pos_to_char_pos(s, 1), 1);
}
#[test]
fn grapheme_pos_to_char_pos_3() {
let s = "\u{000D}\u{000A}";
assert_eq!(grapheme_pos_to_char_pos(s, 0), 0);
assert_eq!(grapheme_pos_to_char_pos(s, 1), 2);
}
#[test]
fn grapheme_pos_to_char_pos_4() {
let s = "";
assert_eq!(grapheme_pos_to_char_pos(s, 0), 0);
}
}

File diff suppressed because it is too large Load Diff