Format ControlFlow changes with rustfmt
This commit is contained in:
parent
d0af12560c
commit
96eb5e1751
@ -1,7 +1,7 @@
|
||||
use crate::cmp;
|
||||
use crate::fmt;
|
||||
use crate::intrinsics;
|
||||
use crate::ops::{Add, AddAssign, Try, ControlFlow};
|
||||
use crate::ops::{Add, AddAssign, ControlFlow, Try};
|
||||
|
||||
use super::from_fn;
|
||||
use super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedLen};
|
||||
|
@ -365,4 +365,3 @@ mod adapters;
|
||||
mod range;
|
||||
mod sources;
|
||||
mod traits;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::ops::{Try, ControlFlow};
|
||||
use crate::ops::{ControlFlow, Try};
|
||||
|
||||
/// An iterator able to yield elements from both ends.
|
||||
///
|
||||
|
@ -3,7 +3,7 @@
|
||||
// can't split that into multiple files.
|
||||
|
||||
use crate::cmp::{self, Ordering};
|
||||
use crate::ops::{Add, Try, ControlFlow};
|
||||
use crate::ops::{Add, ControlFlow, Try};
|
||||
|
||||
use super::super::TrustedRandomAccess;
|
||||
use super::super::{Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse};
|
||||
@ -2234,7 +2234,9 @@ pub trait Iterator {
|
||||
F: FnMut(Self::Item) -> Option<B>,
|
||||
{
|
||||
#[inline]
|
||||
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut((), T) -> ControlFlow<(), B> {
|
||||
fn check<T, B>(
|
||||
mut f: impl FnMut(T) -> Option<B>,
|
||||
) -> impl FnMut((), T) -> ControlFlow<(), B> {
|
||||
move |(), x| match f(x) {
|
||||
Some(x) => ControlFlow::Break(x),
|
||||
None => ControlFlow::Continue(()),
|
||||
@ -2354,7 +2356,11 @@ pub trait Iterator {
|
||||
) -> impl FnMut(usize, T) -> ControlFlow<usize, usize> {
|
||||
// The addition might panic on overflow
|
||||
move |i, x| {
|
||||
if predicate(x) { ControlFlow::Break(i) } else { ControlFlow::Continue(Add::add(i, 1)) }
|
||||
if predicate(x) {
|
||||
ControlFlow::Break(i)
|
||||
} else {
|
||||
ControlFlow::Continue(Add::add(i, 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::ops::Try;
|
||||
|
||||
/// Used to make try_fold closures more like normal loops
|
||||
#[unstable(feature="control_flow_enum", reason="new API", issue="75744")]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum ControlFlow<C, B> {
|
||||
/// Continue in the loop, using the given value for the next iteration
|
||||
@ -10,7 +10,7 @@ pub enum ControlFlow<C, B> {
|
||||
Break(B),
|
||||
}
|
||||
|
||||
#[unstable(feature="control_flow_enum", reason="new API", issue="75744")]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
impl<C, B> Try for ControlFlow<C, B> {
|
||||
type Ok = C;
|
||||
type Error = B;
|
||||
@ -35,7 +35,7 @@ impl<C, B> ControlFlow<C, B> {
|
||||
/// Converts the `ControlFlow` into an `Option` which is `Some` if the
|
||||
/// `ControlFlow` was `Break` and `None` otherwise.
|
||||
#[inline]
|
||||
#[unstable(feature="control_flow_enum", reason="new API", issue="75744")]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
pub fn break_value(self) -> Option<B> {
|
||||
match self {
|
||||
ControlFlow::Continue(..) => None,
|
||||
@ -46,7 +46,7 @@ impl<C, B> ControlFlow<C, B> {
|
||||
|
||||
impl<R: Try> ControlFlow<R::Ok, R> {
|
||||
/// Create a `ControlFlow` from any type implementing `Try`.
|
||||
#[unstable(feature="control_flow_enum", reason="new API", issue="75744")]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
#[inline]
|
||||
pub fn from_try(r: R) -> Self {
|
||||
match Try::into_result(r) {
|
||||
@ -56,7 +56,7 @@ impl<R: Try> ControlFlow<R::Ok, R> {
|
||||
}
|
||||
|
||||
/// Convert a `ControlFlow` into any type implementing `Try`;
|
||||
#[unstable(feature="control_flow_enum", reason="new API", issue="75744")]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
#[inline]
|
||||
pub fn into_try(self) -> R {
|
||||
match self {
|
||||
|
@ -140,6 +140,7 @@
|
||||
|
||||
mod arith;
|
||||
mod bit;
|
||||
mod control_flow;
|
||||
mod deref;
|
||||
mod drop;
|
||||
mod function;
|
||||
@ -148,7 +149,6 @@ mod index;
|
||||
mod range;
|
||||
mod r#try;
|
||||
mod unsize;
|
||||
mod control_flow;
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::arith::{Add, Div, Mul, Neg, Rem, Sub};
|
||||
@ -193,5 +193,5 @@ pub use self::unsize::CoerceUnsized;
|
||||
#[unstable(feature = "dispatch_from_dyn", issue = "none")]
|
||||
pub use self::unsize::DispatchFromDyn;
|
||||
|
||||
#[unstable(feature="control_flow_enum", reason="new API", issue="75744")]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
pub use self::control_flow::ControlFlow;
|
||||
|
Loading…
x
Reference in New Issue
Block a user