Skip to content

Commit 5bde47b

Browse files
authored
Merge pull request #93 from YohDeadfall/fixed-warnings
Fixed unused imports and deprecated pattern warnings
2 parents 1d3e87d + 620ed8c commit 5bde47b

File tree

7 files changed

+27
-31
lines changed

7 files changed

+27
-31
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"

scripts/unicode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def emit_util_mod(f):
229229
#[inline]
230230
fn is_alphabetic(c: char) -> bool {
231231
match c {
232-
'a' ... 'z' | 'A' ... 'Z' => true,
232+
'a' ..= 'z' | 'A' ..= 'Z' => true,
233233
c if c > '\x7f' => super::derived_property::Alphabetic(c),
234234
_ => false,
235235
}
@@ -238,7 +238,7 @@ def emit_util_mod(f):
238238
#[inline]
239239
fn is_numeric(c: char) -> bool {
240240
match c {
241-
'0' ... '9' => true,
241+
'0' ..= '9' => true,
242242
c if c > '\x7f' => super::general_category::N(c),
243243
_ => false,
244244
}
@@ -281,7 +281,6 @@ def emit_break_module(f, break_table, break_cats, name):
281281
f.write(""" }
282282
283283
fn bsearch_range_value_table(c: char, r: &'static [(char, char, %sCat)]) -> (u32, u32, %sCat) {
284-
use core;
285284
use core::cmp::Ordering::{Equal, Less, Greater};
286285
match r.binary_search_by(|&(lo, hi, _)| {
287286
if lo <= c && c <= hi { Equal }

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/tables.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub mod util {
3030
#[inline]
3131
fn is_alphabetic(c: char) -> bool {
3232
match c {
33-
'a' ... 'z' | 'A' ... 'Z' => true,
33+
'a' ..= 'z' | 'A' ..= 'Z' => true,
3434
c if c > '' => super::derived_property::Alphabetic(c),
3535
_ => false,
3636
}
@@ -39,7 +39,7 @@ pub mod util {
3939
#[inline]
4040
fn is_numeric(c: char) -> bool {
4141
match c {
42-
'0' ... '9' => true,
42+
'0' ..= '9' => true,
4343
c if c > '' => super::general_category::N(c),
4444
_ => false,
4545
}
@@ -352,7 +352,6 @@ pub mod grapheme {
352352
}
353353

354354
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> (u32, u32, GraphemeCat) {
355-
use core;
356355
use core::cmp::Ordering::{Equal, Less, Greater};
357356
match r.binary_search_by(|&(lo, hi, _)| {
358357
if lo <= c && c <= hi { Equal }
@@ -1003,7 +1002,6 @@ pub mod word {
10031002
}
10041003

10051004
fn bsearch_range_value_table(c: char, r: &'static [(char, char, WordCat)]) -> (u32, u32, WordCat) {
1006-
use core;
10071005
use core::cmp::Ordering::{Equal, Less, Greater};
10081006
match r.binary_search_by(|&(lo, hi, _)| {
10091007
if lo <= c && c <= hi { Equal }
@@ -1479,7 +1477,6 @@ pub mod emoji {
14791477
}
14801478

14811479
fn bsearch_range_value_table(c: char, r: &'static [(char, char, EmojiCat)]) -> (u32, u32, EmojiCat) {
1482-
use core;
14831480
use core::cmp::Ordering::{Equal, Less, Greater};
14841481
match r.binary_search_by(|&(lo, hi, _)| {
14851482
if lo <= c && c <= hi { Equal }
@@ -1583,7 +1580,6 @@ pub mod sentence {
15831580
}
15841581

15851582
fn bsearch_range_value_table(c: char, r: &'static [(char, char, SentenceCat)]) -> (u32, u32, SentenceCat) {
1586-
use core;
15871583
use core::cmp::Ordering::{Equal, Less, Greater};
15881584
match r.binary_search_by(|&(lo, hi, _)| {
15891585
if lo <= c && c <= hi { Equal }

src/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::prelude::v1::*;
1414

1515
#[test]
1616
fn test_graphemes() {
17-
use testdata::{TEST_SAME, TEST_DIFF};
17+
use crate::testdata::{TEST_SAME, TEST_DIFF};
1818

1919
pub const EXTRA_DIFF: &'static [(&'static str,
2020
&'static [&'static str],
@@ -88,7 +88,7 @@ fn test_graphemes() {
8888

8989
#[test]
9090
fn test_words() {
91-
use testdata::TEST_WORD;
91+
use crate::testdata::TEST_WORD;
9292

9393
// Unicode's official tests don't really test longer chains of flag emoji
9494
// TODO This could be improved with more tests like flag emoji with interspersed Extend chars and ZWJ
@@ -144,7 +144,7 @@ fn test_words() {
144144

145145
#[test]
146146
fn test_sentences() {
147-
use testdata::TEST_SENTENCE;
147+
use crate::testdata::TEST_SENTENCE;
148148

149149
for &(s, w) in TEST_SENTENCE.iter() {
150150
macro_rules! assert_ {

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
}
@@ -413,7 +413,7 @@ impl<'a> DoubleEndedIterator for UWordBounds<'a> {
413413
fn next_back(&mut self) -> Option<&'a str> {
414414
use self::UWordBoundsState::*;
415415
use self::FormatExtendType::*;
416-
use tables::word as wd;
416+
use crate::tables::word as wd;
417417
if self.string.len() == 0 {
418418
return None;
419419
}
@@ -665,7 +665,7 @@ impl<'a> UWordBounds<'a> {
665665

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

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

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

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

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