Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
bf2b4738
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,发现更多精彩内容 >>
提交
bf2b4738
编写于
1月 28, 2015
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename FullRange to RangeFull
上级
c64a96d3
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
134 addition
and
31 deletion
+134
-31
src/libcollections/str.rs
src/libcollections/str.rs
+8
-2
src/libcollections/string.rs
src/libcollections/string.rs
+10
-0
src/libcollections/vec.rs
src/libcollections/vec.rs
+20
-0
src/libcore/ops.rs
src/libcore/ops.rs
+17
-0
src/libcore/slice.rs
src/libcore/slice.rs
+28
-14
src/libcore/str/mod.rs
src/libcore/str/mod.rs
+10
-0
src/librustc/middle/lang_items.rs
src/librustc/middle/lang_items.rs
+1
-1
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/expr.rs
+2
-2
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+2
-2
src/libstd/ffi/os_str.rs
src/libstd/ffi/os_str.rs
+11
-0
src/libstd/path/mod.rs
src/libstd/path/mod.rs
+1
-0
src/libstd/path/windows.rs
src/libstd/path/windows.rs
+1
-0
src/libstd/prelude/v1.rs
src/libstd/prelude/v1.rs
+1
-1
src/libstd/sys/common/wtf8.rs
src/libstd/sys/common/wtf8.rs
+11
-0
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+3
-3
src/test/run-pass/issue-21384.rs
src/test/run-pass/issue-21384.rs
+3
-1
src/test/run-pass/slice.rs
src/test/run-pass/slice.rs
+5
-5
未找到文件。
src/libcollections/str.rs
浏览文件 @
bf2b4738
...
...
@@ -60,7 +60,13 @@
use
core
::
clone
::
Clone
;
use
core
::
iter
::
AdditiveIterator
;
use
core
::
iter
::{
Iterator
,
IteratorExt
};
use
core
::
ops
::{
FullRange
,
Index
};
use
core
::
ops
::
Index
;
#[cfg(stage0)]
use
core
::
ops
::
FullRange
as
RangeFull
;
#[cfg(stage0)]
use
core
::
ops
::
FullRange
;
#[cfg(not(stage0))]
use
core
::
ops
::
RangeFull
;
use
core
::
option
::
Option
::{
self
,
Some
,
None
};
use
core
::
slice
::
AsSlice
;
use
core
::
str
as
core_str
;
...
...
@@ -408,7 +414,7 @@ fn to_owned(&self) -> String {
/// Any string that can be represented as a slice.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
StrExt
:
Index
<
FullRange
,
Output
=
str
>
{
pub
trait
StrExt
:
Index
<
RangeFull
,
Output
=
str
>
{
/// Escapes each char in `s` with `char::escape_default`.
#[unstable(feature
=
"collections"
,
reason
=
"return type may change to be an iterator"
)]
...
...
src/libcollections/string.rs
浏览文件 @
bf2b4738
...
...
@@ -877,6 +877,7 @@ fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
&
self
[][
*
index
]
}
}
#[cfg(stage0)]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
ops
::
Index
<
ops
::
FullRange
>
for
String
{
type
Output
=
str
;
...
...
@@ -885,6 +886,15 @@ fn index(&self, _index: &ops::FullRange) -> &str {
unsafe
{
mem
::
transmute
(
self
.vec
.as_slice
())
}
}
}
#[cfg(not(stage0))]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
ops
::
Index
<
ops
::
RangeFull
>
for
String
{
type
Output
=
str
;
#[inline]
fn
index
(
&
self
,
_
index
:
&
ops
::
RangeFull
)
->
&
str
{
unsafe
{
mem
::
transmute
(
self
.vec
.as_slice
())
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
ops
::
Deref
for
String
{
...
...
src/libcollections/vec.rs
浏览文件 @
bf2b4738
...
...
@@ -1317,6 +1317,7 @@ fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
self
.as_slice
()
.index
(
index
)
}
}
#[cfg(stage0)]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
Index
<
ops
::
FullRange
>
for
Vec
<
T
>
{
type
Output
=
[
T
];
...
...
@@ -1325,6 +1326,15 @@ fn index(&self, _index: &ops::FullRange) -> &[T] {
self
.as_slice
()
}
}
#[cfg(not(stage0))]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
Index
<
ops
::
RangeFull
>
for
Vec
<
T
>
{
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
_
index
:
&
ops
::
RangeFull
)
->
&
[
T
]
{
self
.as_slice
()
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
IndexMut
<
ops
::
Range
<
uint
>>
for
Vec
<
T
>
{
...
...
@@ -1350,6 +1360,7 @@ fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
self
.as_mut_slice
()
.index_mut
(
index
)
}
}
#[cfg(stage0)]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
IndexMut
<
ops
::
FullRange
>
for
Vec
<
T
>
{
type
Output
=
[
T
];
...
...
@@ -1358,6 +1369,15 @@ fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
self
.as_mut_slice
()
}
}
#[cfg(not(stage0))]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
IndexMut
<
ops
::
RangeFull
>
for
Vec
<
T
>
{
type
Output
=
[
T
];
#[inline]
fn
index_mut
(
&
mut
self
,
_
index
:
&
ops
::
RangeFull
)
->
&
mut
[
T
]
{
self
.as_mut_slice
()
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
Deref
for
Vec
<
T
>
{
...
...
src/libcore/ops.rs
浏览文件 @
bf2b4738
...
...
@@ -947,11 +947,20 @@ pub trait IndexMut<Index: ?Sized> {
}
/// An unbounded range.
#[cfg(stage0)]
#[derive(Copy,
Clone,
PartialEq,
Eq)]
#[lang=
"full_range"
]
#[unstable(feature
=
"core"
,
reason
=
"may be renamed to RangeFull"
)]
pub
struct
FullRange
;
/// An unbounded range.
#[cfg(not(stage0))]
#[derive(Copy,
Clone,
PartialEq,
Eq)]
#[lang=
"range_full"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
RangeFull
;
#[cfg(stage0)]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
fmt
::
Debug
for
FullRange
{
fn
fmt
(
&
self
,
fmt
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
...
...
@@ -959,6 +968,14 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
}
}
#[cfg(not(stage0))]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
fmt
::
Debug
for
RangeFull
{
fn
fmt
(
&
self
,
fmt
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fmt
::
Debug
::
fmt
(
".."
,
fmt
)
}
}
/// A (half-open) range which is bounded at both ends.
#[derive(Copy,
Clone,
PartialEq,
Eq)]
#[lang=
"range"
]
...
...
src/libcore/slice.rs
浏览文件 @
bf2b4738
...
...
@@ -44,6 +44,10 @@
use
marker
::
Copy
;
use
num
::
Int
;
use
ops
::{
FnMut
,
self
,
Index
};
#[cfg(stage0)]
use
ops
::
FullRange
as
RangeFull
;
#[cfg(not(stage0))]
use
ops
::
RangeFull
;
use
option
::
Option
;
use
option
::
Option
::{
None
,
Some
};
use
result
::
Result
;
...
...
@@ -543,10 +547,10 @@ fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
Index
<
ops
::
FullRange
>
for
[
T
]
{
impl
<
T
>
ops
::
Index
<
RangeFull
>
for
[
T
]
{
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
_
index
:
&
ops
::
FullRange
)
->
&
[
T
]
{
fn
index
(
&
self
,
_
index
:
&
RangeFull
)
->
&
[
T
]
{
self
}
}
...
...
@@ -584,10 +588,10 @@ fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
ops
::
IndexMut
<
ops
::
FullRange
>
for
[
T
]
{
impl
<
T
>
ops
::
IndexMut
<
RangeFull
>
for
[
T
]
{
type
Output
=
[
T
];
#[inline]
fn
index_mut
(
&
mut
self
,
_
index
:
&
ops
::
FullRange
)
->
&
mut
[
T
]
{
fn
index_mut
(
&
mut
self
,
_
index
:
&
RangeFull
)
->
&
mut
[
T
]
{
self
}
}
...
...
@@ -750,6 +754,7 @@ fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
}
}
#[cfg(stage0)]
#[unstable(feature
=
"core"
)]
impl
<
'a
,
T
>
ops
::
Index
<
ops
::
FullRange
>
for
Iter
<
'a
,
T
>
{
type
Output
=
[
T
];
...
...
@@ -758,6 +763,15 @@ fn index(&self, _index: &ops::FullRange) -> &[T] {
self
.as_slice
()
}
}
#[cfg(not(stage0))]
#[unstable(feature
=
"core"
)]
impl
<
'a
,
T
>
ops
::
Index
<
RangeFull
>
for
Iter
<
'a
,
T
>
{
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
_
index
:
&
RangeFull
)
->
&
[
T
]
{
self
.as_slice
()
}
}
impl
<
'a
,
T
>
Iter
<
'a
,
T
>
{
/// View the underlying data as a subslice of the original data.
...
...
@@ -821,7 +835,7 @@ impl<'a, T> ops::Index<ops::Range<uint>> for IterMut<'a, T> {
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
index
:
&
ops
::
Range
<
uint
>
)
->
&
[
T
]
{
self
.index
(
&
ops
::
FullRange
)
.index
(
index
)
self
.index
(
&
RangeFull
)
.index
(
index
)
}
}
#[unstable(feature
=
"core"
)]
...
...
@@ -829,7 +843,7 @@ impl<'a, T> ops::Index<ops::RangeTo<uint>> for IterMut<'a, T> {
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
index
:
&
ops
::
RangeTo
<
uint
>
)
->
&
[
T
]
{
self
.index
(
&
ops
::
FullRange
)
.index
(
index
)
self
.index
(
&
RangeFull
)
.index
(
index
)
}
}
#[unstable(feature
=
"core"
)]
...
...
@@ -837,14 +851,14 @@ impl<'a, T> ops::Index<ops::RangeFrom<uint>> for IterMut<'a, T> {
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
index
:
&
ops
::
RangeFrom
<
uint
>
)
->
&
[
T
]
{
self
.index
(
&
ops
::
FullRange
)
.index
(
index
)
self
.index
(
&
RangeFull
)
.index
(
index
)
}
}
#[unstable(feature
=
"core"
)]
impl
<
'a
,
T
>
ops
::
Index
<
ops
::
FullRange
>
for
IterMut
<
'a
,
T
>
{
impl
<
'a
,
T
>
ops
::
Index
<
RangeFull
>
for
IterMut
<
'a
,
T
>
{
type
Output
=
[
T
];
#[inline]
fn
index
(
&
self
,
_
index
:
&
ops
::
FullRange
)
->
&
[
T
]
{
fn
index
(
&
self
,
_
index
:
&
RangeFull
)
->
&
[
T
]
{
make_slice!
(
T
=>
&
[
T
]:
self
.ptr
,
self
.end
)
}
}
...
...
@@ -854,7 +868,7 @@ impl<'a, T> ops::IndexMut<ops::Range<uint>> for IterMut<'a, T> {
type
Output
=
[
T
];
#[inline]
fn
index_mut
(
&
mut
self
,
index
:
&
ops
::
Range
<
uint
>
)
->
&
mut
[
T
]
{
self
.index_mut
(
&
ops
::
FullRange
)
.index_mut
(
index
)
self
.index_mut
(
&
RangeFull
)
.index_mut
(
index
)
}
}
#[unstable(feature
=
"core"
)]
...
...
@@ -862,7 +876,7 @@ impl<'a, T> ops::IndexMut<ops::RangeTo<uint>> for IterMut<'a, T> {
type
Output
=
[
T
];
#[inline]
fn
index_mut
(
&
mut
self
,
index
:
&
ops
::
RangeTo
<
uint
>
)
->
&
mut
[
T
]
{
self
.index_mut
(
&
ops
::
FullRange
)
.index_mut
(
index
)
self
.index_mut
(
&
RangeFull
)
.index_mut
(
index
)
}
}
#[unstable(feature
=
"core"
)]
...
...
@@ -870,14 +884,14 @@ impl<'a, T> ops::IndexMut<ops::RangeFrom<uint>> for IterMut<'a, T> {
type
Output
=
[
T
];
#[inline]
fn
index_mut
(
&
mut
self
,
index
:
&
ops
::
RangeFrom
<
uint
>
)
->
&
mut
[
T
]
{
self
.index_mut
(
&
ops
::
FullRange
)
.index_mut
(
index
)
self
.index_mut
(
&
RangeFull
)
.index_mut
(
index
)
}
}
#[unstable(feature
=
"core"
)]
impl
<
'a
,
T
>
ops
::
IndexMut
<
ops
::
FullRange
>
for
IterMut
<
'a
,
T
>
{
impl
<
'a
,
T
>
ops
::
IndexMut
<
RangeFull
>
for
IterMut
<
'a
,
T
>
{
type
Output
=
[
T
];
#[inline]
fn
index_mut
(
&
mut
self
,
_
index
:
&
ops
::
FullRange
)
->
&
mut
[
T
]
{
fn
index_mut
(
&
mut
self
,
_
index
:
&
RangeFull
)
->
&
mut
[
T
]
{
make_slice!
(
T
=>
&
mut
[
T
]:
self
.ptr
,
self
.end
)
}
}
...
...
src/libcore/str/mod.rs
浏览文件 @
bf2b4738
...
...
@@ -1249,6 +1249,7 @@ fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
}
}
#[cfg(stage0)]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
ops
::
Index
<
ops
::
FullRange
>
for
str
{
type
Output
=
str
;
...
...
@@ -1257,6 +1258,15 @@ fn index(&self, _index: &ops::FullRange) -> &str {
self
}
}
#[cfg(not(stage0))]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
ops
::
Index
<
ops
::
RangeFull
>
for
str
{
type
Output
=
str
;
#[inline]
fn
index
(
&
self
,
_
index
:
&
ops
::
RangeFull
)
->
&
str
{
self
}
}
}
/// Any string that can be represented as a slice
...
...
src/librustc/middle/lang_items.rs
浏览文件 @
bf2b4738
...
...
@@ -269,7 +269,7 @@ pub fn collect_language_items(krate: &ast::Crate,
RangeStructLangItem
,
"range"
,
range_struct
;
RangeFromStructLangItem
,
"range_from"
,
range_from_struct
;
RangeToStructLangItem
,
"range_to"
,
range_to_struct
;
FullRangeStructLangItem
,
"full_range"
,
full_range
_struct
;
RangeFullStructLangItem
,
"range_full"
,
range_full
_struct
;
UnsafeTypeLangItem
,
"unsafe"
,
unsafe_type
;
...
...
src/librustc_trans/trans/expr.rs
浏览文件 @
bf2b4738
...
...
@@ -1050,8 +1050,8 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
(
tcx
.lang_items
.range_to_struct
(),
fields
,
vec!
[
node_id_type
(
bcx
,
end
.id
)])
}
_
=>
{
// Desugar to
FullRange
(
tcx
.lang_items
.
full_range
_struct
(),
vec!
[],
vec!
[])
// Desugar to
RangeFull
(
tcx
.lang_items
.
range_full
_struct
(),
vec!
[],
vec!
[])
}
};
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
bf2b4738
...
...
@@ -4095,8 +4095,8 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
}
}
None
=>
{
// Neither start nor end =>
FullRange
if
let
Some
(
did
)
=
tcx
.lang_items
.
full_range
_struct
()
{
// Neither start nor end =>
RangeFull
if
let
Some
(
did
)
=
tcx
.lang_items
.
range_full
_struct
()
{
let
substs
=
Substs
::
new_type
(
vec!
[],
vec!
[]);
ty
::
mk_struct
(
tcx
,
did
,
tcx
.mk_substs
(
substs
))
}
else
{
...
...
src/libstd/ffi/os_str.rs
浏览文件 @
bf2b4738
...
...
@@ -82,6 +82,7 @@ pub fn push_os_str(&mut self, s: &OsStr) {
}
}
#[cfg(stage0)]
impl
ops
::
Index
<
ops
::
FullRange
>
for
OsString
{
type
Output
=
OsStr
;
...
...
@@ -91,6 +92,16 @@ fn index(&self, _index: &ops::FullRange) -> &OsStr {
}
}
#[cfg(not(stage0))]
impl
ops
::
Index
<
ops
::
RangeFull
>
for
OsString
{
type
Output
=
OsStr
;
#[inline]
fn
index
(
&
self
,
_
index
:
&
ops
::
RangeFull
)
->
&
OsStr
{
unsafe
{
mem
::
transmute
(
self
.inner
.as_slice
())
}
}
}
impl
ops
::
Deref
for
OsString
{
type
Target
=
OsStr
;
...
...
src/libstd/path/mod.rs
浏览文件 @
bf2b4738
...
...
@@ -68,6 +68,7 @@
use
iter
::
IteratorExt
;
use
option
::
Option
;
use
option
::
Option
::{
None
,
Some
};
#[cfg(stage0)]
use
ops
::
FullRange
;
use
str
;
use
str
::
StrExt
;
...
...
src/libstd/path/windows.rs
浏览文件 @
bf2b4738
...
...
@@ -25,6 +25,7 @@
use
iter
::{
Iterator
,
IteratorExt
,
Map
,
repeat
};
use
mem
;
use
option
::
Option
::{
self
,
Some
,
None
};
#[cfg(stage0)]
use
ops
::
FullRange
;
use
slice
::{
SliceExt
,
SliceConcatExt
};
use
str
::{
SplitTerminator
,
FromStr
,
StrExt
};
...
...
src/libstd/prelude/v1.rs
浏览文件 @
bf2b4738
...
...
@@ -18,7 +18,7 @@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[doc(no_inline)]
pub
use
ops
::{
Drop
,
Fn
,
FnMut
,
FnOnce
};
// TEMPORARY
#[cfg(stage0)]
#[unstable(feature
=
"std_misc"
)]
#[doc(no_inline)]
pub
use
ops
::
FullRange
;
...
...
src/libstd/sys/common/wtf8.rs
浏览文件 @
bf2b4738
...
...
@@ -680,6 +680,7 @@ fn index(&self, range: &ops::RangeTo<usize>) -> &Wtf8 {
}
}
#[cfg(stage0)]
impl
ops
::
Index
<
ops
::
FullRange
>
for
Wtf8
{
type
Output
=
Wtf8
;
...
...
@@ -689,6 +690,16 @@ fn index(&self, _range: &ops::FullRange) -> &Wtf8 {
}
}
#[cfg(not(stage0))]
impl
ops
::
Index
<
ops
::
RangeFull
>
for
Wtf8
{
type
Output
=
Wtf8
;
#[inline]
fn
index
(
&
self
,
_
range
:
&
ops
::
RangeFull
)
->
&
Wtf8
{
self
}
}
#[inline]
fn
decode_surrogate
(
second_byte
:
u8
,
third_byte
:
u8
)
->
u16
{
// The first byte is assumed to be 0xED
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
bf2b4738
...
...
@@ -2527,14 +2527,14 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
}
if
found_dotdot
||
self
.eat
(
&
token
::
CloseDelim
(
token
::
Bracket
))
{
// No expression, expand to a
FullRange
// No expression, expand to a
RangeFull
// FIXME(#20516) It would be better to use a lang item or
// something for
FullRange
.
// something for
RangeFull
.
hi
=
self
.last_span.hi
;
let
idents
=
vec!
[
token
::
str_to_ident
(
"core"
),
token
::
str_to_ident
(
"ops"
),
token
::
str_to_ident
(
"
FullRange
"
)];
token
::
str_to_ident
(
"
RangeFull
"
)];
let
segments
=
idents
.into_iter
()
.map
(|
ident
|
{
ast
::
PathSegment
{
identifier
:
ident
,
...
...
src/test/run-pass/issue-21384.rs
浏览文件 @
bf2b4738
...
...
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
::
core
::
ops
::
RangeFull
;
fn
test
<
T
:
Clone
>
(
arg
:
T
)
->
T
{
arg
.clone
()
}
...
...
@@ -20,7 +22,7 @@ fn main() {
assert
!
(
test
(
1
..
5
)
==
(
1
..
5
));
assert
!
(
test
(
..
5
)
==
(
..
5
));
assert
!
(
test
(
1
..
)
==
(
1
..
));
assert
!
(
test
(
FullRange
)
==
(
FullRange
));
assert
!
(
test
(
RangeFull
)
==
(
RangeFull
));
// Check that ranges can still be used with non-clone limits
assert
!
((
Test
(
1
)
..
Test
(
5
))
==
(
Test
(
1
)
..
Test
(
5
)));
...
...
src/test/run-pass/slice.rs
浏览文件 @
bf2b4738
...
...
@@ -13,7 +13,7 @@
#![feature(associated_types)]
extern
crate
core
;
use
core
::
ops
::{
Index
,
IndexMut
,
Range
,
RangeTo
,
RangeFrom
,
FullRange
};
use
core
::
ops
::{
Index
,
IndexMut
,
Range
,
RangeTo
,
RangeFrom
,
RangeFull
};
static
mut
COUNT
:
uint
=
0
;
...
...
@@ -40,9 +40,9 @@ fn index(&self, index: &RangeFrom<Foo>) -> &Foo {
self
}
}
impl
Index
<
FullRange
>
for
Foo
{
impl
Index
<
RangeFull
>
for
Foo
{
type
Output
=
Foo
;
fn
index
(
&
self
,
_
index
:
&
FullRange
)
->
&
Foo
{
fn
index
(
&
self
,
_
index
:
&
RangeFull
)
->
&
Foo
{
unsafe
{
COUNT
+=
1
;
}
self
}
...
...
@@ -69,9 +69,9 @@ fn index_mut(&mut self, index: &RangeFrom<Foo>) -> &mut Foo {
self
}
}
impl
IndexMut
<
FullRange
>
for
Foo
{
impl
IndexMut
<
RangeFull
>
for
Foo
{
type
Output
=
Foo
;
fn
index_mut
(
&
mut
self
,
_
index
:
&
FullRange
)
->
&
mut
Foo
{
fn
index_mut
(
&
mut
self
,
_
index
:
&
RangeFull
)
->
&
mut
Foo
{
unsafe
{
COUNT
+=
1
;
}
self
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录