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

Commit7cedb2f

Browse files
committed
Removed 'regex' and 'lazy_static' dependency
1 parent6ff9442 commit7cedb2f

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

‎iui/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,4 @@ bitflags = "1"
4040
libc ="0.2"
4141
failure ="0.1"
4242
ui-sys = {path ="../ui-sys",version ="0.2.1" }
43-
regex ="1"
44-
lazy_static ="1"
4543

‎iui/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
externcrate bitflags;
2222
#[macro_use]
2323
externcrate failure;
24-
#[macro_use]
25-
externcrate lazy_static;
2624
externcrate libc;
27-
externcrate regex;
2825
externcrate ui_sys;
2926

3027
mod callback_helpers;

‎iui/src/str_tools.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Tools for making platform-independent string handling work properly
22
3-
use regex::{Regex,RegexBuilder};
43
use std::ffi::{CStr,CString};
54
use std::os::raw::c_char;
65

@@ -10,16 +9,19 @@ pub fn strip_dual_endings(s: &str) -> String {
109
s.replace("\r\n","\n")
1110
}
1211

13-
/// Replaces everyoccurrance of `"\n"` notfollowed by `"\r"` with `"\r\n"`.
12+
/// Replaces everyoccurrence of `"\n"` notled by `"\r"` with `"\r\n"`.
1413
pubfninsert_dual_endings(s:&str) ->String{
15-
lazy_static!{
16-
//static ref RE: Regex = Regex::new("([^\r])\n").expect("Could not compile regex");
17-
static refRE:Regex =RegexBuilder::new("\r\n|\n")
18-
.multi_line(true)
19-
.build()
20-
.expect("Could not compile regex");
14+
letmut ns =String::with_capacity(s.len() +2);
15+
letmut cr =false;
16+
for(_, d)in s.char_indices(){
17+
if d =='\n' && !cr{
18+
ns.push('\r');
19+
}
20+
21+
ns.push(d);
22+
cr = d =='\r';
2123
}
22-
RE.replace_all(s,"\r\n").to_string()
24+
return ns;
2325
}
2426

2527
/// Converts a &str to a CString, using either LF or CRLF as appropriate.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp