Skip to content

Commit fe89bc6

Browse files
committed
Updated edition to 2018
1 parent 8f9bd66 commit fe89bc6

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name = "unicode-segmentation"
44
version = "1.7.1"
55
authors = ["kwantam <[email protected]>", "Manish Goregaokar <[email protected]>"]
66

7+
edition = "2018"
78
homepage = "https://github.com/unicode-rs/unicode-segmentation"
89
repository = "https://github.com/unicode-rs/unicode-segmentation"
910
documentation = "https://unicode-rs.github.io/unicode-segmentation"

src/grapheme.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use core::cmp;
1212

13-
use tables::grapheme::GraphemeCat;
13+
use crate::tables::grapheme::GraphemeCat;
1414

1515
/// External iterator for grapheme clusters and byte offsets.
1616
///
@@ -229,7 +229,7 @@ enum PairResult {
229229
}
230230

231231
fn check_pair(before: GraphemeCat, after: GraphemeCat) -> PairResult {
232-
use tables::grapheme::GraphemeCat::*;
232+
use crate::tables::grapheme::GraphemeCat::*;
233233
use self::PairResult::*;
234234
match (before, after) {
235235
(GC_CR, GC_LF) => NotBreak, // GB3
@@ -295,8 +295,8 @@ impl GraphemeCursor {
295295
}
296296

297297
fn grapheme_category(&mut self, ch: char) -> GraphemeCat {
298-
use tables::grapheme as gr;
299-
use tables::grapheme::GraphemeCat::*;
298+
use crate::tables::grapheme as gr;
299+
use crate::tables::grapheme::GraphemeCat::*;
300300

301301
if ch <= '\u{7e}' {
302302
// Special-case optimization for ascii, except U+007F. This
@@ -387,7 +387,7 @@ impl GraphemeCursor {
387387
/// assert_eq!(cursor.is_boundary(&flags[8..], 8), Ok(true));
388388
/// ```
389389
pub fn provide_context(&mut self, chunk: &str, chunk_start: usize) {
390-
use tables::grapheme as gr;
390+
use crate::tables::grapheme as gr;
391391
assert!(chunk_start + chunk.len() == self.pre_context_offset.unwrap());
392392
self.pre_context_offset = None;
393393
if self.is_extended && chunk_start + chunk.len() == self.offset {
@@ -433,7 +433,7 @@ impl GraphemeCursor {
433433
}
434434

435435
fn handle_regional(&mut self, chunk: &str, chunk_start: usize) {
436-
use tables::grapheme as gr;
436+
use crate::tables::grapheme as gr;
437437
let mut ris_count = self.ris_count.unwrap_or(0);
438438
for ch in chunk.chars().rev() {
439439
if self.grapheme_category(ch) != gr::GC_Regional_Indicator {
@@ -453,7 +453,7 @@ impl GraphemeCursor {
453453
}
454454

455455
fn handle_emoji(&mut self, chunk: &str, chunk_start: usize) {
456-
use tables::grapheme as gr;
456+
use crate::tables::grapheme as gr;
457457
let mut iter = chunk.chars().rev();
458458
if let Some(ch) = iter.next() {
459459
if self.grapheme_category(ch) != gr::GC_ZWJ {
@@ -506,7 +506,7 @@ impl GraphemeCursor {
506506
/// assert_eq!(cursor.is_boundary(flags, 0), Ok(false));
507507
/// ```
508508
pub fn is_boundary(&mut self, chunk: &str, chunk_start: usize) -> Result<bool, GraphemeIncomplete> {
509-
use tables::grapheme as gr;
509+
use crate::tables::grapheme as gr;
510510
if self.state == GraphemeState::Break {
511511
return Ok(true)
512512
}

src/sentence.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::iter::Filter;
1313

1414
// All of the logic for forward iteration over sentences
1515
mod fwd {
16-
use tables::sentence::SentenceCat;
16+
use crate::tables::sentence::SentenceCat;
1717
use core::cmp;
1818

1919
// Describe a parsed part of source string as described in this table:
@@ -111,7 +111,7 @@ mod fwd {
111111
if parts[idx] == StatePart::ClosePlus { idx -= 1 }
112112

113113
if parts[idx] == StatePart::ATerm {
114-
use tables::sentence as se;
114+
use crate::tables::sentence as se;
115115

116116
for next_char in ahead.chars() {
117117
//( ¬(OLetter | Upper | Lower | ParaSep | SATerm) )* Lower
@@ -176,7 +176,7 @@ mod fwd {
176176

177177
#[inline]
178178
fn next(&mut self) -> Option<usize> {
179-
use tables::sentence as se;
179+
use crate::tables::sentence as se;
180180

181181
for next_char in self.string[self.pos..].chars() {
182182
let position_before = self.pos;
@@ -331,7 +331,7 @@ pub fn new_sentence_bound_indices<'a>(source: &'a str) -> USentenceBoundIndices<
331331
#[inline]
332332
pub fn new_unicode_sentences<'b>(s: &'b str) -> UnicodeSentences<'b> {
333333
use super::UnicodeSegmentation;
334-
use tables::util::is_alphanumeric;
334+
use crate::tables::util::is_alphanumeric;
335335

336336
fn has_alphanumeric(s: &&str) -> bool { s.chars().any(|c| is_alphanumeric(c)) }
337337
let has_alphanumeric: fn(&&str) -> bool = has_alphanumeric; // coerce to fn pointer

src/word.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use core::cmp;
1212
use core::iter::Filter;
1313

14-
use tables::word::WordCat;
14+
use crate::tables::word::WordCat;
1515

1616
/// An iterator over the substrings of a string which, after splitting the string on
1717
/// [word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries),
@@ -142,7 +142,7 @@ enum RegionalState {
142142
}
143143

144144
fn is_emoji(ch: char) -> bool {
145-
use tables::emoji;
145+
use crate::tables::emoji;
146146
emoji::emoji_category(ch).2 == emoji::EmojiCat::EC_Extended_Pictographic
147147
}
148148

@@ -159,7 +159,7 @@ impl<'a> Iterator for UWordBounds<'a> {
159159
fn next(&mut self) -> Option<&'a str> {
160160
use self::UWordBoundsState::*;
161161
use self::FormatExtendType::*;
162-
use tables::word as wd;
162+
use crate::tables::word as wd;
163163
if self.string.len() == 0 {
164164
return None;
165165
}
@@ -386,7 +386,7 @@ impl<'a> DoubleEndedIterator for UWordBounds<'a> {
386386
fn next_back(&mut self) -> Option<&'a str> {
387387
use self::UWordBoundsState::*;
388388
use self::FormatExtendType::*;
389-
use tables::word as wd;
389+
use crate::tables::word as wd;
390390
if self.string.len() == 0 {
391391
return None;
392392
}
@@ -638,7 +638,7 @@ impl<'a> UWordBounds<'a> {
638638

639639
#[inline]
640640
fn get_next_cat(&self, idx: usize) -> Option<WordCat> {
641-
use tables::word as wd;
641+
use crate::tables::word as wd;
642642
let nidx = idx + self.string[idx..].chars().next().unwrap().len_utf8();
643643
if nidx < self.string.len() {
644644
let nch = self.string[nidx..].chars().next().unwrap();
@@ -650,7 +650,7 @@ impl<'a> UWordBounds<'a> {
650650

651651
#[inline]
652652
fn get_prev_cat(&self, idx: usize) -> Option<WordCat> {
653-
use tables::word as wd;
653+
use crate::tables::word as wd;
654654
if idx > 0 {
655655
let nch = self.string[..idx].chars().next_back().unwrap();
656656
Some(wd::word_category(nch).2)
@@ -673,7 +673,7 @@ pub fn new_word_bound_indices<'b>(s: &'b str) -> UWordBoundIndices<'b> {
673673
#[inline]
674674
pub fn new_unicode_words<'b>(s: &'b str) -> UnicodeWords<'b> {
675675
use super::UnicodeSegmentation;
676-
use tables::util::is_alphanumeric;
676+
use crate::tables::util::is_alphanumeric;
677677

678678
fn has_alphanumeric(s: &&str) -> bool { s.chars().any(|c| is_alphanumeric(c)) }
679679
let has_alphanumeric: fn(&&str) -> bool = has_alphanumeric; // coerce to fn pointer

0 commit comments

Comments
 (0)