Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
scie
提交
bae11955
S
scie
项目概览
Phodal
/
scie
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scie
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
bae11955
编写于
9月 10, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: align sizes
上级
d9f0d8a3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
20 deletion
+22
-20
scie-scanner/src/scanner/old/scie_error.rs
scie-scanner/src/scanner/old/scie_error.rs
+3
-4
scie-scanner/src/scanner/old/scie_onig.rs
scie-scanner/src/scanner/old/scie_onig.rs
+1
-1
scie-scanner/src/scanner/onig_string.rs
scie-scanner/src/scanner/onig_string.rs
+18
-15
未找到文件。
scie-scanner/src/scanner/old/scie_error.rs
浏览文件 @
bae11955
...
...
@@ -23,7 +23,6 @@
use
std
::
os
::
raw
::
c_int
;
use
std
::
ptr
::
null
;
use
std
::{
error
,
fmt
,
str
};
/// This struture represents an error from the underlying Oniguruma libray.
...
...
@@ -37,9 +36,9 @@ impl ScieOnigError {
ScieOnigError
::
new
(
code
,
info
)
}
fn
from_code
(
code
:
c_int
)
->
ScieOnigError
{
ScieOnigError
::
new
(
code
,
null
())
}
//
fn from_code(code: c_int) -> ScieOnigError {
//
ScieOnigError::new(code, null())
//
}
fn
new
(
code
:
c_int
,
info
:
*
const
onig_sys
::
OnigErrorInfo
)
->
ScieOnigError
{
let
buff
=
&
mut
[
0
;
onig_sys
::
ONIG_MAX_ERROR_MESSAGE_LEN
as
usize
];
...
...
scie-scanner/src/scanner/old/scie_onig.rs
浏览文件 @
bae11955
...
...
@@ -70,7 +70,7 @@ mod tests {
#[test]
fn
it_works
()
{
ScieOnig
::
demo_new
(
r"^"
);
let
_
result
=
ScieOnig
::
demo_new
(
r"^"
);
assert
!
(
true
)
}
}
scie-scanner/src/scanner/onig_string.rs
浏览文件 @
bae11955
use
unicode_segmentation
::
UnicodeSegmentation
;
#[derive(Clone,
Debug)]
pub
struct
OnigString
{
pub
utf16length
:
i32
,
pub
utf8length
:
i32
,
pub
utf16value
:
String
,
pub
utf8value
:
Vec
<
u8
>
,
pub
utf16offset_to_utf8
:
Option
<
Vec
<
u32
>>
,
pub
utf8offset_to_utf16
:
Option
<
Vec
<
u32
>>
,
pub
utf16length
:
i32
,
pub
utf8length
:
i32
,
pub
utf16value
:
String
,
pub
utf8value
:
Vec
<
u8
>
,
pub
utf16offset_to_utf8
:
Option
<
Vec
<
u32
>>
,
pub
utf8offset_to_utf16
:
Option
<
Vec
<
u32
>>
,
}
impl
OnigString
{
pub
fn
new
(
str
:
String
)
->
Self
{
let
utf16length
=
str
.len
();
let
utf
8_str
=
str
.graphemes
(
true
)
.collect
::
<
Vec
<&
str
>>
()
.clone
();
println!
(
"{:?}"
,
utf8_str
);
let
utf8length
=
utf8_
str
.len
();
let
mut
utf16_vec
:
Vec
<
u16
>
=
str
.encode_utf16
()
.collect
();
let
utf
16length
=
utf16_vec
.len
();
// let utf8_str = str.graphemes(true).collect::<Vec<&str>>().clone(
);
let
utf8length
=
str
.len
();
let
utf8value
=
str
.clone
()
.into_bytes
();
OnigString
{
utf16length
:
utf16length
as
i32
,
utf8length
:
utf8length
as
i32
,
utf16value
:
""
.to_string
(),
utf8value
:
vec!
[]
,
utf16value
:
str
.clone
(),
utf8value
,
utf16offset_to_utf8
:
None
,
utf8offset_to_utf16
:
None
}
...
...
@@ -37,7 +38,9 @@ mod tests {
#[test]
fn
it_show_works_works
()
{
let
onig_string
=
OnigString
::
new
(
String
::
from
(
"a💻bYX"
));
assert_eq!
(
8
,
onig_string
.utf16length
);
assert_eq!
(
5
,
onig_string
.utf8length
);
println!
(
"{:?}"
,
onig_string
);
assert_eq!
(
6
,
onig_string
.utf16length
);
assert_eq!
(
8
,
onig_string
.utf8length
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录