Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5bde47b

Browse files
authored
Merge pull request#93 from YohDeadfall/fixed-warnings
Fixed unused imports and deprecated pattern warnings
2 parents1d3e87d +620ed8c commit5bde47b

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+
usecrate::tables::grapheme::GraphemeCat;
1414

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

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

297297
fngrapheme_category(&mutself,ch:char) ->GraphemeCat{
298-
use tables::graphemeas gr;
299-
use tables::grapheme::GraphemeCat::*;
298+
usecrate::tables::graphemeas gr;
299+
usecrate::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
pubfnprovide_context(&mutself,chunk:&str,chunk_start:usize){
390-
use tables::graphemeas gr;
390+
usecrate::tables::graphemeas gr;
391391
assert!(chunk_start + chunk.len() ==self.pre_context_offset.unwrap());
392392
self.pre_context_offset =None;
393393
ifself.is_extended && chunk_start + chunk.len() ==self.offset{
@@ -433,7 +433,7 @@ impl GraphemeCursor {
433433
}
434434

435435
fnhandle_regional(&mutself,chunk:&str,chunk_start:usize){
436-
use tables::graphemeas gr;
436+
usecrate::tables::graphemeas gr;
437437
letmut ris_count =self.ris_count.unwrap_or(0);
438438
for chin chunk.chars().rev(){
439439
ifself.grapheme_category(ch) != gr::GC_Regional_Indicator{
@@ -453,7 +453,7 @@ impl GraphemeCursor {
453453
}
454454

455455
fnhandle_emoji(&mutself,chunk:&str,chunk_start:usize){
456-
use tables::graphemeas gr;
456+
usecrate::tables::graphemeas gr;
457457
letmut iter = chunk.chars().rev();
458458
ifletSome(ch) = iter.next(){
459459
ifself.grapheme_category(ch) != gr::GC_ZWJ{
@@ -506,7 +506,7 @@ impl GraphemeCursor {
506506
/// assert_eq!(cursor.is_boundary(flags, 0), Ok(false));
507507
/// ```
508508
pubfnis_boundary(&mutself,chunk:&str,chunk_start:usize) ->Result<bool,GraphemeIncomplete>{
509-
use tables::graphemeas gr;
509+
usecrate::tables::graphemeas gr;
510510
ifself.state ==GraphemeState::Break{
511511
returnOk(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+
usecrate::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::sentenceas se;
114+
usecrate::tables::sentenceas se;
115115

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

177177
#[inline]
178178
fnnext(&mutself) ->Option<usize>{
179-
use tables::sentenceas se;
179+
usecrate::tables::sentenceas se;
180180

181181
for next_charinself.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
pubfnnew_unicode_sentences<'b>(s:&'bstr) ->UnicodeSentences<'b>{
333333
usesuper::UnicodeSegmentation;
334-
use tables::util::is_alphanumeric;
334+
usecrate::tables::util::is_alphanumeric;
335335

336336
fnhas_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
fnis_alphabetic(c:char) ->bool{
3232
match c{
33-
'a' ...'z' |'A' ...'Z' =>true,
33+
'a' ..='z' |'A' ..='Z' =>true,
3434
cif c >'' =>super::derived_property::Alphabetic(c),
3535
_ =>false,
3636
}
@@ -39,7 +39,7 @@ pub mod util {
3939
#[inline]
4040
fnis_numeric(c:char) ->bool{
4141
match c{
42-
'0' ...'9' =>true,
42+
'0' ..='9' =>true,
4343
cif c >'' =>super::general_category::N(c),
4444
_ =>false,
4545
}
@@ -352,7 +352,6 @@ pub mod grapheme {
352352
}
353353

354354
fnbsearch_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
fnbsearch_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
fnbsearch_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
fnbsearch_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
fntest_graphemes(){
17-
use testdata::{TEST_SAME,TEST_DIFF};
17+
usecrate::testdata::{TEST_SAME,TEST_DIFF};
1818

1919
pubconstEXTRA_DIFF:&'static[(&'staticstr,
2020
&'static[&'staticstr],
@@ -88,7 +88,7 @@ fn test_graphemes() {
8888

8989
#[test]
9090
fntest_words(){
91-
use testdata::TEST_WORD;
91+
usecrate::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
fntest_sentences(){
147-
use testdata::TEST_SENTENCE;
147+
usecrate::testdata::TEST_SENTENCE;
148148

149149
for&(s, w)inTEST_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+
usecrate::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
fnis_emoji(ch:char) ->bool{
173-
use tables::emoji;
173+
usecrate::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
fnnext(&mutself) ->Option<&'astr>{
188188
useself::UWordBoundsState::*;
189189
useself::FormatExtendType::*;
190-
use tables::wordas wd;
190+
usecrate::tables::wordas wd;
191191
ifself.string.len() ==0{
192192
returnNone;
193193
}
@@ -413,7 +413,7 @@ impl<'a> DoubleEndedIterator for UWordBounds<'a> {
413413
fnnext_back(&mutself) ->Option<&'astr>{
414414
useself::UWordBoundsState::*;
415415
useself::FormatExtendType::*;
416-
use tables::wordas wd;
416+
usecrate::tables::wordas wd;
417417
ifself.string.len() ==0{
418418
returnNone;
419419
}
@@ -665,7 +665,7 @@ impl<'a> UWordBounds<'a> {
665665

666666
#[inline]
667667
fnget_next_cat(&self,idx:usize) ->Option<WordCat>{
668-
use tables::wordas wd;
668+
usecrate::tables::wordas 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
fnget_prev_cat(&self,idx:usize) ->Option<WordCat>{
680-
use tables::wordas wd;
680+
usecrate::tables::wordas 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
fnhas_alphanumeric(s:&&str) ->bool{
702-
use tables::util::is_alphanumeric;
702+
usecrate::tables::util::is_alphanumeric;
703703

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp