Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d9bc3cb1
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d9bc3cb1
编写于
8月 23, 2011
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change "pred" to "pure fn" in all libraries and test cases
上级
1cb85015
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
33 addition
and
31 deletion
+33
-31
src/lib/char.rs
src/lib/char.rs
+1
-1
src/lib/istr.rs
src/lib/istr.rs
+2
-2
src/lib/uint.rs
src/lib/uint.rs
+6
-6
src/lib/vec.rs
src/lib/vec.rs
+2
-2
src/test/compile-fail/constrained-type-missing-check.rs
src/test/compile-fail/constrained-type-missing-check.rs
+1
-1
src/test/compile-fail/do-while-pred-constraints.rs
src/test/compile-fail/do-while-pred-constraints.rs
+1
-1
src/test/compile-fail/if-check-precond-fail.rs
src/test/compile-fail/if-check-precond-fail.rs
+1
-1
src/test/compile-fail/impure-pred.rs
src/test/compile-fail/impure-pred.rs
+1
-1
src/test/compile-fail/not-pred-args.rs
src/test/compile-fail/not-pred-args.rs
+1
-1
src/test/compile-fail/pred-assign.rs
src/test/compile-fail/pred-assign.rs
+1
-1
src/test/compile-fail/pred-on-wrong-slots.rs
src/test/compile-fail/pred-on-wrong-slots.rs
+1
-1
src/test/compile-fail/pred-swap.rs
src/test/compile-fail/pred-swap.rs
+1
-1
src/test/compile-fail/while-loop-pred-constraints.rs
src/test/compile-fail/while-loop-pred-constraints.rs
+1
-1
src/test/run-fail/if-check-fail.rs
src/test/run-fail/if-check-fail.rs
+1
-1
src/test/run-fail/pred.rs
src/test/run-fail/pred.rs
+1
-1
src/test/run-pass/claim-nonterm.rs
src/test/run-pass/claim-nonterm.rs
+1
-1
src/test/run-pass/constrained-type.rs
src/test/run-pass/constrained-type.rs
+1
-1
src/test/run-pass/if-check-precond.rs
src/test/run-pass/if-check-precond.rs
+1
-1
src/test/run-pass/if-check.rs
src/test/run-pass/if-check.rs
+1
-1
src/test/run-pass/pred-check.rs
src/test/run-pass/pred-check.rs
+1
-1
src/test/run-pass/pred-not-bool.rs
src/test/run-pass/pred-not-bool.rs
+2
-0
src/test/run-pass/pred.rs
src/test/run-pass/pred.rs
+1
-1
src/test/run-pass/typestate-transitive.rs
src/test/run-pass/typestate-transitive.rs
+1
-1
src/test/run-pass/wierd-exprs.rs
src/test/run-pass/wierd-exprs.rs
+1
-1
src/test/stdtest/vec.rs
src/test/stdtest/vec.rs
+1
-1
未找到文件。
src/lib/char.rs
浏览文件 @
d9bc3cb1
p
red
is_whitespace
(
c
:
char
)
->
bool
{
p
ure
fn
is_whitespace
(
c
:
char
)
->
bool
{
const
ch_space
:
char
=
'\u0020'
;
const
ch_space
:
char
=
'\u0020'
;
const
ch_ogham_space_mark
:
char
=
'\u1680'
;
const
ch_ogham_space_mark
:
char
=
'\u1680'
;
const
ch_mongolian_vowel_sep
:
char
=
'\u180e'
;
const
ch_mongolian_vowel_sep
:
char
=
'\u180e'
;
...
...
src/lib/istr.rs
浏览文件 @
d9bc3cb1
...
@@ -73,12 +73,12 @@ fn is_ascii(s: &istr) -> bool {
...
@@ -73,12 +73,12 @@ fn is_ascii(s: &istr) -> bool {
}
}
/// Returns true if the string has length 0
/// Returns true if the string has length 0
p
red
is_empty
(
s
:
&
istr
)
->
bool
{
p
ure
fn
is_empty
(
s
:
&
istr
)
->
bool
{
for
c
:
u8
in
s
{
ret
false
;
}
ret
true
;
for
c
:
u8
in
s
{
ret
false
;
}
ret
true
;
}
}
/// Returns true if the string has length greater than 0
/// Returns true if the string has length greater than 0
p
red
is_not_empty
(
s
:
&
istr
)
->
bool
{
p
ure
fn
is_not_empty
(
s
:
&
istr
)
->
bool
{
!
is_empty
(
s
)
!
is_empty
(
s
)
}
}
...
...
src/lib/uint.rs
浏览文件 @
d9bc3cb1
...
@@ -10,17 +10,17 @@
...
@@ -10,17 +10,17 @@
fn
rem
(
x
:
uint
,
y
:
uint
)
->
uint
{
ret
x
%
y
;
}
fn
rem
(
x
:
uint
,
y
:
uint
)
->
uint
{
ret
x
%
y
;
}
p
red
lt
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
<
y
;
}
p
ure
fn
lt
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
<
y
;
}
p
red
le
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
<=
y
;
}
p
ure
fn
le
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
<=
y
;
}
p
red
eq
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
==
y
;
}
p
ure
fn
eq
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
==
y
;
}
p
red
ne
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
!=
y
;
}
p
ure
fn
ne
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
!=
y
;
}
p
red
ge
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
>=
y
;
}
p
ure
fn
ge
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
>=
y
;
}
p
red
gt
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
>
y
;
}
p
ure
fn
gt
(
x
:
uint
,
y
:
uint
)
->
bool
{
ret
x
>
y
;
}
fn
max
(
x
:
uint
,
y
:
uint
)
->
uint
{
if
x
>
y
{
ret
x
;
}
ret
y
;
}
fn
max
(
x
:
uint
,
y
:
uint
)
->
uint
{
if
x
>
y
{
ret
x
;
}
ret
y
;
}
...
...
src/lib/vec.rs
浏览文件 @
d9bc3cb1
...
@@ -77,13 +77,13 @@ fn from_mut<@T>(v: &[mutable T]) -> [T] {
...
@@ -77,13 +77,13 @@ fn from_mut<@T>(v: &[mutable T]) -> [T] {
}
}
// Predicates
// Predicates
p
red
is_empty
<
T
>
(
v
:
&
[
mutable
?
T
])
->
bool
{
p
ure
fn
is_empty
<
T
>
(
v
:
&
[
mutable
?
T
])
->
bool
{
// FIXME: This would be easier if we could just call len
// FIXME: This would be easier if we could just call len
for
t
:
T
in
v
{
ret
false
;
}
for
t
:
T
in
v
{
ret
false
;
}
ret
true
;
ret
true
;
}
}
p
red
is_not_empty
<
T
>
(
v
:
&
[
mutable
?
T
])
->
bool
{
ret
!
is_empty
(
v
);
}
p
ure
fn
is_not_empty
<
T
>
(
v
:
&
[
mutable
?
T
])
->
bool
{
ret
!
is_empty
(
v
);
}
// Accessors
// Accessors
...
...
src/test/compile-fail/constrained-type-missing-check.rs
浏览文件 @
d9bc3cb1
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
type
bubu
=
{
x
:
int
,
y
:
int
};
type
bubu
=
{
x
:
int
,
y
:
int
};
p
red
less_than
(
x
:
int
,
y
:
int
)
->
bool
{
ret
x
<
y
;
}
p
ure
fn
less_than
(
x
:
int
,
y
:
int
)
->
bool
{
ret
x
<
y
;
}
type
ordered_range
=
{
low
:
int
,
high
:
int
}
:
less_than
(
low
,
high
);
type
ordered_range
=
{
low
:
int
,
high
:
int
}
:
less_than
(
low
,
high
);
...
...
src/test/compile-fail/do-while-pred-constraints.rs
浏览文件 @
d9bc3cb1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
fn
print_even
(
y
:
int
)
:
even
(
y
)
{
log
y
;
}
fn
print_even
(
y
:
int
)
:
even
(
y
)
{
log
y
;
}
p
red
even
(
y
:
int
)
->
bool
{
true
}
p
ure
fn
even
(
y
:
int
)
->
bool
{
true
}
fn
main
()
{
fn
main
()
{
let
y
:
int
=
42
;
let
y
:
int
=
42
;
...
...
src/test/compile-fail/if-check-precond-fail.rs
浏览文件 @
d9bc3cb1
// error-pattern:Unsatisfied precondition constraint
// error-pattern:Unsatisfied precondition constraint
p
red
even
(
x
:
uint
)
->
bool
{
p
ure
fn
even
(
x
:
uint
)
->
bool
{
if
x
<
2u
{
if
x
<
2u
{
ret
false
;
ret
false
;
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
...
...
src/test/compile-fail/impure-pred.rs
浏览文件 @
d9bc3cb1
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
fn
g
()
{
}
fn
g
()
{
}
p
red
f
(
q
:
int
)
->
bool
{
g
();
ret
true
;
}
p
ure
fn
f
(
q
:
int
)
->
bool
{
g
();
ret
true
;
}
fn
main
()
{
fn
main
()
{
let
x
=
0
;
let
x
=
0
;
...
...
src/test/compile-fail/not-pred-args.rs
浏览文件 @
d9bc3cb1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// error-pattern: Constraint args must be
// error-pattern: Constraint args must be
p
red
f
(
q
:
int
)
->
bool
{
ret
true
;
}
p
ure
fn
f
(
q
:
int
)
->
bool
{
ret
true
;
}
fn
main
()
{
fn
main
()
{
// should fail to typecheck, as pred args must be slot variables
// should fail to typecheck, as pred args must be slot variables
...
...
src/test/compile-fail/pred-assign.rs
浏览文件 @
d9bc3cb1
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
fn
f
(
a
:
int
,
b
:
int
)
:
lt
(
a
,
b
)
{
}
fn
f
(
a
:
int
,
b
:
int
)
:
lt
(
a
,
b
)
{
}
p
red
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
p
ure
fn
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
fn
main
()
{
fn
main
()
{
let
a
:
int
=
10
;
let
a
:
int
=
10
;
...
...
src/test/compile-fail/pred-on-wrong-slots.rs
浏览文件 @
d9bc3cb1
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
fn
f
(
a
:
int
,
b
:
int
)
:
lt
(
a
,
b
)
{
}
fn
f
(
a
:
int
,
b
:
int
)
:
lt
(
a
,
b
)
{
}
p
red
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
p
ure
fn
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
fn
main
()
{
fn
main
()
{
let
a
:
int
=
10
;
let
a
:
int
=
10
;
...
...
src/test/compile-fail/pred-swap.rs
浏览文件 @
d9bc3cb1
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
fn
f
(
a
:
int
,
b
:
int
)
:
lt
(
a
,
b
)
{
}
fn
f
(
a
:
int
,
b
:
int
)
:
lt
(
a
,
b
)
{
}
p
red
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
p
ure
fn
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
fn
main
()
{
fn
main
()
{
let
a
:
int
=
10
;
let
a
:
int
=
10
;
...
...
src/test/compile-fail/while-loop-pred-constraints.rs
浏览文件 @
d9bc3cb1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
fn
print_even
(
y
:
int
)
:
even
(
y
)
{
log
y
;
}
fn
print_even
(
y
:
int
)
:
even
(
y
)
{
log
y
;
}
p
red
even
(
y
:
int
)
->
bool
{
true
}
p
ure
fn
even
(
y
:
int
)
->
bool
{
true
}
fn
main
()
{
fn
main
()
{
...
...
src/test/run-fail/if-check-fail.rs
浏览文件 @
d9bc3cb1
// error-pattern:Number is odd
// error-pattern:Number is odd
p
red
even
(
x
:
uint
)
->
bool
{
p
ure
fn
even
(
x
:
uint
)
->
bool
{
if
x
<
2u
{
if
x
<
2u
{
ret
false
;
ret
false
;
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
...
...
src/test/run-fail/pred.rs
浏览文件 @
d9bc3cb1
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
// error-pattern:Predicate lt(b, a) failed
// error-pattern:Predicate lt(b, a) failed
fn
f
(
a
:
int
,
b
:
int
)
{
}
fn
f
(
a
:
int
,
b
:
int
)
{
}
p
red
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
p
ure
fn
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
fn
main
()
{
let
a
:
int
=
10
;
let
b
:
int
=
23
;
check
(
lt
(
b
,
a
));
f
(
b
,
a
);
}
fn
main
()
{
let
a
:
int
=
10
;
let
b
:
int
=
23
;
check
(
lt
(
b
,
a
));
f
(
b
,
a
);
}
src/test/run-pass/claim-nonterm.rs
浏览文件 @
d9bc3cb1
...
@@ -3,6 +3,6 @@
...
@@ -3,6 +3,6 @@
import
std
::
str
::
*
;
import
std
::
str
::
*
;
import
std
::
uint
::
*
;
import
std
::
uint
::
*
;
p
red
fails
(
a
:
uint
)
->
bool
{
fail
;
}
p
ure
fn
fails
(
a
:
uint
)
->
bool
{
fail
;
}
fn
main
()
{
let
b
:
uint
=
4u
;
claim
(
fails
(
b
));
}
fn
main
()
{
let
b
:
uint
=
4u
;
claim
(
fails
(
b
));
}
src/test/run-pass/constrained-type.rs
浏览文件 @
d9bc3cb1
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
type
bubu
=
{
x
:
int
,
y
:
int
};
type
bubu
=
{
x
:
int
,
y
:
int
};
p
red
less_than
(
x
:
int
,
y
:
int
)
->
bool
{
ret
x
<
y
;
}
p
ure
fn
less_than
(
x
:
int
,
y
:
int
)
->
bool
{
ret
x
<
y
;
}
type
ordered_range
=
{
low
:
int
,
high
:
int
}
:
less_than
(
*
.low
,
*
.high
);
type
ordered_range
=
{
low
:
int
,
high
:
int
}
:
less_than
(
*
.low
,
*
.high
);
...
...
src/test/run-pass/if-check-precond.rs
浏览文件 @
d9bc3cb1
p
red
even
(
x
:
uint
)
->
bool
{
p
ure
fn
even
(
x
:
uint
)
->
bool
{
if
x
<
2u
{
if
x
<
2u
{
ret
false
;
ret
false
;
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
...
...
src/test/run-pass/if-check.rs
浏览文件 @
d9bc3cb1
p
red
even
(
x
:
uint
)
->
bool
{
p
ure
fn
even
(
x
:
uint
)
->
bool
{
if
x
<
2u
{
if
x
<
2u
{
ret
false
;
ret
false
;
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
}
else
if
x
==
2u
{
ret
true
;
}
else
{
ret
even
(
x
-
2u
);
}
...
...
src/test/run-pass/pred-check.rs
浏览文件 @
d9bc3cb1
// -*- rust -*-
// -*- rust -*-
p
red
f
(
q
:
int
)
->
bool
{
ret
true
;
}
p
ure
fn
f
(
q
:
int
)
->
bool
{
ret
true
;
}
fn
main
()
{
let
x
=
0
;
check
(
f
(
x
));
}
fn
main
()
{
let
x
=
0
;
check
(
f
(
x
));
}
src/test/run-pass/pred-not-bool.rs
浏览文件 @
d9bc3cb1
// FIXME should be in run-pass
// -*- rust -*-
// -*- rust -*-
// error-pattern: Non-boolean return type
// error-pattern: Non-boolean return type
...
...
src/test/run-pass/pred.rs
浏览文件 @
d9bc3cb1
// -*- rust -*-
// -*- rust -*-
fn
f
(
a
:
int
,
b
:
int
)
{
}
fn
f
(
a
:
int
,
b
:
int
)
{
}
p
red
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
p
ure
fn
lt
(
a
:
int
,
b
:
int
)
->
bool
{
ret
a
<
b
;
}
fn
main
()
{
fn
main
()
{
let
a
:
int
=
10
;
let
a
:
int
=
10
;
...
...
src/test/run-pass/typestate-transitive.rs
浏览文件 @
d9bc3cb1
p
red
p
(
i
:
int
)
->
bool
{
true
}
p
ure
fn
p
(
i
:
int
)
->
bool
{
true
}
fn
f
(
i
:
int
)
:
p
(
i
)
->
int
{
i
}
fn
f
(
i
:
int
)
:
p
(
i
)
->
int
{
i
}
...
...
src/test/run-pass/wierd-exprs.rs
浏览文件 @
d9bc3cb1
...
@@ -40,7 +40,7 @@ fn hammertime() -> int {
...
@@ -40,7 +40,7 @@ fn hammertime() -> int {
}
}
fn
canttouchthis
()
->
uint
{
fn
canttouchthis
()
->
uint
{
p
red
p
()
->
bool
{
true
}
p
ure
fn
p
()
->
bool
{
true
}
let
_
a
=
(
assert
(
true
))
==
(
check
(
p
()));
let
_
a
=
(
assert
(
true
))
==
(
check
(
p
()));
let
_
c
=
(
check
(
p
()))
==
();
let
_
c
=
(
check
(
p
()))
==
();
let
_
b
=
(
log
0
)
==
(
ret
0u
);
let
_
b
=
(
log
0
)
==
(
ret
0u
);
...
...
src/test/stdtest/vec.rs
浏览文件 @
d9bc3cb1
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
fn
square_alias
(
n
:
&
uint
)
->
uint
{
ret
n
*
n
;
}
fn
square_alias
(
n
:
&
uint
)
->
uint
{
ret
n
*
n
;
}
p
red
is_three
(
n
:
&
uint
)
->
bool
{
ret
n
==
3u
;
}
p
ure
fn
is_three
(
n
:
&
uint
)
->
bool
{
ret
n
==
3u
;
}
fn
square_if_odd
(
n
:
&
uint
)
->
option
::
t
<
uint
>
{
fn
square_if_odd
(
n
:
&
uint
)
->
option
::
t
<
uint
>
{
ret
if
n
%
2u
==
1u
{
some
(
n
*
n
)
}
else
{
none
};
ret
if
n
%
2u
==
1u
{
some
(
n
*
n
)
}
else
{
none
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录