Skip to content

Commit 866197c

Browse files
committed
Updated edition to 2018
1 parent ee33287 commit 866197c

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 <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"]
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),
@@ -170,7 +170,7 @@ enum RegionalState {
170170
}
171171

172172
fn is_emoji(ch: char) -> bool {
173-
use tables::emoji;
173+
use crate::tables::emoji;
174174
emoji::emoji_category(ch).2 == emoji::EmojiCat::EC_Extended_Pictographic
175175
}
176176

@@ -187,7 +187,7 @@ impl<'a> Iterator for UWordBounds<'a> {
187187
fn next(&mut self) -> Option<&'a str> {
188188
use self::UWordBoundsState::*;
189189
use self::FormatExtendType::*;
190-
use tables::word as wd;
190+
use crate::tables::word as wd;
191191
if self.string.len() == 0 {
192192
return None;
193193
}
@@ -414,7 +414,7 @@ impl<'a> DoubleEndedIterator for UWordBounds<'a> {
414414
fn next_back(&mut self) -> Option<&'a str> {
415415
use self::UWordBoundsState::*;
416416
use self::FormatExtendType::*;
417-
use tables::word as wd;
417+
use crate::tables::word as wd;
418418
if self.string.len() == 0 {
419419
return None;
420420
}
@@ -666,7 +666,7 @@ impl<'a> UWordBounds<'a> {
666666

667667
#[inline]
668668
fn get_next_cat(&self, idx: usize) -> Option<WordCat> {
669-
use tables::word as wd;
669+
use crate::tables::word as wd;
670670
let nidx = idx + self.string[idx..].chars().next().unwrap().len_utf8();
671671
if nidx < self.string.len() {
672672
let nch = self.string[nidx..].chars().next().unwrap();
@@ -678,7 +678,7 @@ impl<'a> UWordBounds<'a> {
678678

679679
#[inline]
680680
fn get_prev_cat(&self, idx: usize) -> Option<WordCat> {
681-
use tables::word as wd;
681+
use crate::tables::word as wd;
682682
if idx > 0 {
683683
let nch = self.string[..idx].chars().next_back().unwrap();
684684
Some(wd::word_category(nch).2)
@@ -700,7 +700,7 @@ pub fn new_word_bound_indices<'b>(s: &'b str) -> UWordBoundIndices<'b> {
700700

701701
#[inline]
702702
fn has_alphanumeric(s: &&str) -> bool {
703-
use tables::util::is_alphanumeric;
703+
use crate::tables::util::is_alphanumeric;
704704

705705
s.chars().any(|c| is_alphanumeric(c))
706706
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy