Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
266ca31f
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,发现更多精彩内容 >>
提交
266ca31f
编写于
3月 12, 2019
作者:
S
Steven Malis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stabilize Range*::contains.
上级
8f4c226f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
34 deletion
+20
-34
src/libcore/ops/range.rs
src/libcore/ops/range.rs
+19
-30
src/librustc_codegen_llvm/lib.rs
src/librustc_codegen_llvm/lib.rs
+0
-1
src/librustc_errors/lib.rs
src/librustc_errors/lib.rs
+0
-1
src/librustc_mir/lib.rs
src/librustc_mir/lib.rs
+0
-1
src/libstd/lib.rs
src/libstd/lib.rs
+1
-1
未找到文件。
src/libcore/ops/range.rs
浏览文件 @
266ca31f
...
...
@@ -67,7 +67,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
/// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
/// ```
#[doc(alias
=
".."
)]
#[derive(Clone,
PartialEq,
Eq,
Hash)]
// not Copy -- see #27186
#[derive(Clone,
PartialEq,
Eq,
Hash)]
// not Copy -- see #27186
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Range
<
Idx
>
{
/// The lower bound of the range (inclusive).
...
...
@@ -91,8 +91,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_contains)]
///
/// use std::f32;
///
/// assert!(!(3..5).contains(&2));
...
...
@@ -108,7 +106,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// assert!(!(0.0..f32::NAN).contains(&0.5));
/// assert!(!(f32::NAN..1.0).contains(&0.5));
/// ```
#[
unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311
"
)]
#[
stable(feature
=
"range_contains"
,
since
=
"1.35.0
"
)]
pub
fn
contains
<
U
>
(
&
self
,
item
:
&
U
)
->
bool
where
Idx
:
PartialOrd
<
U
>
,
...
...
@@ -169,7 +167,7 @@ pub fn is_empty(&self) -> bool {
///
/// [`Iterator`]: ../iter/trait.IntoIterator.html
#[doc(alias
=
".."
)]
#[derive(Clone,
PartialEq,
Eq,
Hash)]
// not Copy -- see #27186
#[derive(Clone,
PartialEq,
Eq,
Hash)]
// not Copy -- see #27186
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
RangeFrom
<
Idx
>
{
/// The lower bound of the range (inclusive).
...
...
@@ -190,8 +188,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_contains)]
///
/// use std::f32;
///
/// assert!(!(3..).contains(&2));
...
...
@@ -202,7 +198,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
/// assert!(!(0.0..).contains(&f32::NAN));
/// assert!(!(f32::NAN..).contains(&0.5));
/// ```
#[
unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311
"
)]
#[
stable(feature
=
"range_contains"
,
since
=
"1.35.0
"
)]
pub
fn
contains
<
U
>
(
&
self
,
item
:
&
U
)
->
bool
where
Idx
:
PartialOrd
<
U
>
,
...
...
@@ -272,8 +268,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_contains)]
///
/// use std::f32;
///
/// assert!( (..5).contains(&-1_000_000_000));
...
...
@@ -284,7 +278,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// assert!(!(..1.0).contains(&f32::NAN));
/// assert!(!(..f32::NAN).contains(&0.5));
/// ```
#[
unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311
"
)]
#[
stable(feature
=
"range_contains"
,
since
=
"1.35.0
"
)]
pub
fn
contains
<
U
>
(
&
self
,
item
:
&
U
)
->
bool
where
Idx
:
PartialOrd
<
U
>
,
...
...
@@ -317,7 +311,7 @@ pub fn contains<U>(&self, item: &U) -> bool
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
/// ```
#[doc(alias
=
"..="
)]
#[derive(Clone)]
// not Copy -- see #27186
#[derive(Clone)]
// not Copy -- see #27186
#[stable(feature
=
"inclusive_range"
,
since
=
"1.26.0"
)]
pub
struct
RangeInclusive
<
Idx
>
{
pub
(
crate
)
start
:
Idx
,
...
...
@@ -353,7 +347,8 @@ fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool {
impl
<
Idx
:
PartialEq
>
PartialEq
for
RangeInclusive
<
Idx
>
{
#[inline]
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
{
self
.start
==
other
.start
&&
self
.end
==
other
.end
self
.start
==
other
.start
&&
self
.end
==
other
.end
&&
RangeInclusiveEquality
::
canonicalized_is_empty
(
self
)
==
RangeInclusiveEquality
::
canonicalized_is_empty
(
other
)
}
...
...
@@ -385,7 +380,11 @@ impl<Idx> RangeInclusive<Idx> {
#[inline]
#[rustc_promotable]
pub
const
fn
new
(
start
:
Idx
,
end
:
Idx
)
->
Self
{
Self
{
start
,
end
,
is_empty
:
None
}
Self
{
start
,
end
,
is_empty
:
None
,
}
}
/// Returns the lower bound of the range (inclusive).
...
...
@@ -466,8 +465,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_contains)]
///
/// use std::f32;
///
/// assert!(!(3..=5).contains(&2));
...
...
@@ -484,7 +481,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// assert!(!(0.0..=f32::NAN).contains(&0.0));
/// assert!(!(f32::NAN..=1.0).contains(&1.0));
/// ```
#[
unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311
"
)]
#[
stable(feature
=
"range_contains"
,
since
=
"1.35.0
"
)]
pub
fn
contains
<
U
>
(
&
self
,
item
:
&
U
)
->
bool
where
Idx
:
PartialOrd
<
U
>
,
...
...
@@ -593,15 +590,12 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
}
}
#[unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311"
)]
impl
<
Idx
:
PartialOrd
<
Idx
>>
RangeToInclusive
<
Idx
>
{
/// Returns `true` if `item` is contained in the range.
///
/// # Examples
///
/// ```
/// #![feature(range_contains)]
///
/// use std::f32;
///
/// assert!( (..=5).contains(&-1_000_000_000));
...
...
@@ -612,7 +606,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
/// assert!(!(..=1.0).contains(&f32::NAN));
/// assert!(!(..=f32::NAN).contains(&0.5));
/// ```
#[
unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311
"
)]
#[
stable(feature
=
"range_contains"
,
since
=
"1.35.0
"
)]
pub
fn
contains
<
U
>
(
&
self
,
item
:
&
U
)
->
bool
where
Idx
:
PartialOrd
<
U
>
,
...
...
@@ -714,14 +708,11 @@ pub trait RangeBounds<T: ?Sized> {
#[stable(feature
=
"collections_range"
,
since
=
"1.28.0"
)]
fn
end_bound
(
&
self
)
->
Bound
<&
T
>
;
/// Returns `true` if `item` is contained in the range.
///
/// # Examples
///
/// ```
/// #![feature(range_contains)]
///
/// use std::f32;
///
/// assert!( (3..5).contains(&4));
...
...
@@ -731,7 +722,7 @@ pub trait RangeBounds<T: ?Sized> {
/// assert!(!(0.0..1.0).contains(&f32::NAN));
/// assert!(!(0.0..f32::NAN).contains(&0.5));
/// assert!(!(f32::NAN..1.0).contains(&0.5));
#[
unstable(feature
=
"range_contains"
,
reason
=
"recently added as per RFC"
,
issue
=
"32311
"
)]
#[
stable(feature
=
"range_contains"
,
since
=
"1.35.0
"
)]
fn
contains
<
U
>
(
&
self
,
item
:
&
U
)
->
bool
where
T
:
PartialOrd
<
U
>
,
...
...
@@ -741,9 +732,7 @@ fn contains<U>(&self, item: &U) -> bool
Included
(
ref
start
)
=>
*
start
<=
item
,
Excluded
(
ref
start
)
=>
*
start
<
item
,
Unbounded
=>
true
,
})
&&
(
match
self
.end_bound
()
{
})
&&
(
match
self
.end_bound
()
{
Included
(
ref
end
)
=>
item
<=
*
end
,
Excluded
(
ref
end
)
=>
item
<
*
end
,
Unbounded
=>
true
,
...
...
@@ -819,7 +808,7 @@ fn start_bound(&self) -> Bound<&T> {
match
*
self
{
(
Included
(
ref
start
),
_
)
=>
Included
(
start
),
(
Excluded
(
ref
start
),
_
)
=>
Excluded
(
start
),
(
Unbounded
,
_
)
=>
Unbounded
,
(
Unbounded
,
_
)
=>
Unbounded
,
}
}
...
...
@@ -827,7 +816,7 @@ fn end_bound(&self) -> Bound<&T> {
match
*
self
{
(
_
,
Included
(
ref
end
))
=>
Included
(
end
),
(
_
,
Excluded
(
ref
end
))
=>
Excluded
(
end
),
(
_
,
Unbounded
)
=>
Unbounded
,
(
_
,
Unbounded
)
=>
Unbounded
,
}
}
}
...
...
src/librustc_codegen_llvm/lib.rs
浏览文件 @
266ca31f
...
...
@@ -15,7 +15,6 @@
#![allow(unused_attributes)]
#![feature(libc)]
#![feature(nll)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]
#![feature(optin_builtin_traits)]
#![feature(concat_idents)]
...
...
src/librustc_errors/lib.rs
浏览文件 @
266ca31f
...
...
@@ -2,7 +2,6 @@
#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![feature(range_contains)]
#![cfg_attr(unix,
feature(libc))]
#![feature(nll)]
#![feature(optin_builtin_traits)]
...
...
src/librustc_mir/lib.rs
浏览文件 @
266ca31f
...
...
@@ -14,7 +14,6 @@
#![feature(const_fn)]
#![feature(decl_macro)]
#![feature(exhaustive_patterns)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_attrs)]
#![feature(never_type)]
...
...
src/libstd/lib.rs
浏览文件 @
266ca31f
...
...
@@ -221,7 +221,7 @@
#![cfg_attr(test,
feature(print_internals,
set_stdio,
test,
update_panic_count))]
#![cfg_attr(all(target_vendor
=
"fortanix"
,
target_env
=
"sgx"
),
feature(global_asm,
range_contains,
slice_index_methods,
feature(global_asm,
slice_index_methods,
decl_macro,
coerce_unsized,
sgx_platform,
ptr_wrapping_offset_from))]
// std is implemented with unstable features, many of which are internal
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录