mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Auto merge of #32054 - seanmonstar:impl-debug-core, r=alexcrichton
libcore: add Debug implementations to most missing types Also adds `#![deny(missing_debug_implementations)]` to the core crate. cc #31869
This commit is contained in:
commit
7ec8f5c369
@ -416,14 +416,14 @@ pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option<usize> {
|
||||
///
|
||||
/// [`escape_unicode()`]: ../../std/primitive.char.html#method.escape_unicode
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct EscapeUnicode {
|
||||
c: char,
|
||||
state: EscapeUnicodeState
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
enum EscapeUnicodeState {
|
||||
Backslash,
|
||||
Type,
|
||||
@ -496,13 +496,13 @@ impl Iterator for EscapeUnicode {
|
||||
///
|
||||
/// [`escape_default()`]: ../../std/primitive.char.html#method.escape_default
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct EscapeDefault {
|
||||
state: EscapeDefaultState
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
enum EscapeDefaultState {
|
||||
Backslash(char),
|
||||
Char(char),
|
||||
|
@ -54,6 +54,7 @@ impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b> {
|
||||
///
|
||||
/// Constructed by the `Formatter::debug_struct` method.
|
||||
#[must_use]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub struct DebugStruct<'a, 'b: 'a> {
|
||||
fmt: &'a mut fmt::Formatter<'b>,
|
||||
@ -120,6 +121,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
|
||||
///
|
||||
/// Constructed by the `Formatter::debug_tuple` method.
|
||||
#[must_use]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub struct DebugTuple<'a, 'b: 'a> {
|
||||
fmt: &'a mut fmt::Formatter<'b>,
|
||||
@ -231,6 +233,7 @@ impl<'a, 'b: 'a> DebugInner<'a, 'b> {
|
||||
///
|
||||
/// Constructed by the `Formatter::debug_set` method.
|
||||
#[must_use]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub struct DebugSet<'a, 'b: 'a> {
|
||||
inner: DebugInner<'a, 'b>,
|
||||
@ -279,6 +282,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
|
||||
///
|
||||
/// Constructed by the `Formatter::debug_list` method.
|
||||
#[must_use]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub struct DebugList<'a, 'b: 'a> {
|
||||
inner: DebugInner<'a, 'b>,
|
||||
@ -327,6 +331,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
|
||||
///
|
||||
/// Constructed by the `Formatter::debug_map` method.
|
||||
#[must_use]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub struct DebugMap<'a, 'b: 'a> {
|
||||
fmt: &'a mut fmt::Formatter<'b>,
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
use prelude::v1::*;
|
||||
|
||||
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
|
||||
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut, BorrowState};
|
||||
use marker::PhantomData;
|
||||
use mem;
|
||||
use num::flt2dec;
|
||||
@ -25,6 +25,7 @@ use str;
|
||||
|
||||
#[unstable(feature = "fmt_flags_align", issue = "27726")]
|
||||
/// Possible alignments returned by `Formatter::align`
|
||||
#[derive(Debug)]
|
||||
pub enum Alignment {
|
||||
/// Indication that contents should be left-aligned.
|
||||
Left,
|
||||
@ -152,6 +153,7 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W {
|
||||
/// A struct to represent both where to emit formatting strings to and how they
|
||||
/// should be formatted. A mutable version of this is passed to all formatting
|
||||
/// traits.
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Formatter<'a> {
|
||||
flags: u32,
|
||||
@ -175,6 +177,7 @@ enum Void {}
|
||||
/// compile time it is ensured that the function and the value have the correct
|
||||
/// types, and then this struct is used to canonicalize arguments to one type.
|
||||
#[derive(Copy)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
|
||||
issue = "0")]
|
||||
#[doc(hidden)]
|
||||
@ -1585,7 +1588,9 @@ impl<T: ?Sized> Debug for PhantomData<T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: Copy + Debug> Debug for Cell<T> {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
write!(f, "Cell {{ value: {:?} }}", self.get())
|
||||
f.debug_struct("Cell")
|
||||
.field("value", &self.get())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1594,9 +1599,15 @@ impl<T: ?Sized + Debug> Debug for RefCell<T> {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self.borrow_state() {
|
||||
BorrowState::Unused | BorrowState::Reading => {
|
||||
write!(f, "RefCell {{ value: {:?} }}", self.borrow())
|
||||
f.debug_struct("RefCell")
|
||||
.field("value", &self.borrow())
|
||||
.finish()
|
||||
}
|
||||
BorrowState::Writing => {
|
||||
f.debug_struct("RefCell")
|
||||
.field("value", &"<borrowed>")
|
||||
.finish()
|
||||
}
|
||||
BorrowState::Writing => write!(f, "RefCell {{ <borrowed> }}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1615,5 +1626,12 @@ impl<'b, T: ?Sized + Debug> Debug for RefMut<'b, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<T: ?Sized + Debug> Debug for UnsafeCell<T> {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
f.pad("UnsafeCell")
|
||||
}
|
||||
}
|
||||
|
||||
// If you expected tests to be here, look instead at the run-pass/ifmt.rs test,
|
||||
// it's a lot easier than creating all of the rt::Piece structures here.
|
||||
|
@ -13,6 +13,7 @@
|
||||
//!
|
||||
//! These definitions are similar to their `ct` equivalents, but differ in that
|
||||
//! these can be statically allocated and are slightly optimized for the runtime
|
||||
#![allow(missing_debug_implementations)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Argument {
|
||||
|
@ -73,6 +73,7 @@
|
||||
|
||||
use prelude::v1::*;
|
||||
|
||||
use fmt;
|
||||
use marker;
|
||||
use mem;
|
||||
|
||||
@ -215,6 +216,13 @@ pub trait BuildHasher {
|
||||
#[stable(since = "1.7.0", feature = "build_hasher")]
|
||||
pub struct BuildHasherDefault<H>(marker::PhantomData<H>);
|
||||
|
||||
#[stable(since = "1.9.0", feature = "core_impl_debug")]
|
||||
impl<H> fmt::Debug for BuildHasherDefault<H> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.pad("BuildHasherDefault")
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(since = "1.7.0", feature = "build_hasher")]
|
||||
impl<H: Default + Hasher> BuildHasher for BuildHasherDefault<H> {
|
||||
type Hasher = H;
|
||||
|
@ -30,6 +30,7 @@ use super::Hasher;
|
||||
/// Although the SipHash algorithm is considered to be generally strong,
|
||||
/// it is not intended for cryptographic purposes. As such, all
|
||||
/// cryptographic uses of this implementation are _strongly discouraged_.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct SipHasher {
|
||||
k0: u64,
|
||||
|
@ -303,6 +303,7 @@ use clone::Clone;
|
||||
use cmp;
|
||||
use cmp::{Ord, PartialOrd, PartialEq, Ordering};
|
||||
use default::Default;
|
||||
use fmt;
|
||||
use marker;
|
||||
use mem;
|
||||
use num::{Zero, One};
|
||||
@ -2929,7 +2930,7 @@ impl<A, B> ExactSizeIterator for Zip<A, B>
|
||||
///
|
||||
/// [`rev()`]: trait.Iterator.html#method.rev
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Rev<T> {
|
||||
@ -2961,7 +2962,7 @@ impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator {
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[stable(feature = "iter_cloned", since = "1.1.0")]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Cloned<I> {
|
||||
it: I,
|
||||
}
|
||||
@ -3002,7 +3003,7 @@ impl<'a, I, T: 'a> ExactSizeIterator for Cloned<I>
|
||||
///
|
||||
/// [`cycle()`]: trait.Iterator.html#method.cycle
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Cycle<I> {
|
||||
@ -3040,7 +3041,7 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator {
|
||||
///
|
||||
/// [`chain()`]: trait.Iterator.html#method.chain
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Chain<A, B> {
|
||||
@ -3062,7 +3063,7 @@ pub struct Chain<A, B> {
|
||||
//
|
||||
// The fourth state (neither iterator is remaining) only occurs after Chain has
|
||||
// returned None once, so we don't need to store this state.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
enum ChainState {
|
||||
// both front and back iterator are remaining
|
||||
Both,
|
||||
@ -3184,7 +3185,7 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
|
||||
///
|
||||
/// [`zip()`]: trait.Iterator.html#method.zip
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Zip<A, B> {
|
||||
@ -3307,6 +3308,15 @@ pub struct Map<I, F> {
|
||||
f: F,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, F> fmt::Debug for Map<I, F> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Map")
|
||||
.field("iter", &self.iter)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {
|
||||
type Item = B;
|
||||
@ -3347,6 +3357,15 @@ pub struct Filter<I, P> {
|
||||
predicate: P,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, P> fmt::Debug for Filter<I, P> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Filter")
|
||||
.field("iter", &self.iter)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool {
|
||||
type Item = I::Item;
|
||||
@ -3398,6 +3417,15 @@ pub struct FilterMap<I, F> {
|
||||
f: F,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, F> fmt::Debug for FilterMap<I, F> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("FilterMap")
|
||||
.field("iter", &self.iter)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
|
||||
where F: FnMut(I::Item) -> Option<B>,
|
||||
@ -3443,7 +3471,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for FilterMap<I, F>
|
||||
///
|
||||
/// [`enumerate()`]: trait.Iterator.html#method.enumerate
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Enumerate<I> {
|
||||
@ -3517,7 +3545,7 @@ impl<I> DoubleEndedIterator for Enumerate<I> where
|
||||
///
|
||||
/// [`peekable()`]: trait.Iterator.html#method.peekable
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Peekable<I: Iterator> {
|
||||
@ -3676,6 +3704,16 @@ pub struct SkipWhile<I, P> {
|
||||
predicate: P,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, P> fmt::Debug for SkipWhile<I, P> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SkipWhile")
|
||||
.field("iter", &self.iter)
|
||||
.field("flag", &self.flag)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: Iterator, P> Iterator for SkipWhile<I, P>
|
||||
where P: FnMut(&I::Item) -> bool
|
||||
@ -3716,6 +3754,16 @@ pub struct TakeWhile<I, P> {
|
||||
predicate: P,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, P> fmt::Debug for TakeWhile<I, P> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("TakeWhile")
|
||||
.field("iter", &self.iter)
|
||||
.field("flag", &self.flag)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: Iterator, P> Iterator for TakeWhile<I, P>
|
||||
where P: FnMut(&I::Item) -> bool
|
||||
@ -3752,7 +3800,7 @@ impl<I: Iterator, P> Iterator for TakeWhile<I, P>
|
||||
///
|
||||
/// [`skip()`]: trait.Iterator.html#method.skip
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Skip<I> {
|
||||
@ -3843,7 +3891,7 @@ impl<I> DoubleEndedIterator for Skip<I> where I: DoubleEndedIterator + ExactSize
|
||||
///
|
||||
/// [`take()`]: trait.Iterator.html#method.take
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Take<I> {
|
||||
@ -3914,6 +3962,16 @@ pub struct Scan<I, St, F> {
|
||||
state: St,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, St: fmt::Debug, F> fmt::Debug for Scan<I, St, F> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Scan")
|
||||
.field("iter", &self.iter)
|
||||
.field("state", &self.state)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<B, I, St, F> Iterator for Scan<I, St, F> where
|
||||
I: Iterator,
|
||||
@ -3951,6 +4009,19 @@ pub struct FlatMap<I, U: IntoIterator, F> {
|
||||
backiter: Option<U::IntoIter>,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, U: IntoIterator, F> fmt::Debug for FlatMap<I, U, F>
|
||||
where U::IntoIter: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("FlatMap")
|
||||
.field("iter", &self.iter)
|
||||
.field("frontiter", &self.frontiter)
|
||||
.field("backiter", &self.backiter)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: Iterator, U: IntoIterator, F> Iterator for FlatMap<I, U, F>
|
||||
where F: FnMut(I::Item) -> U,
|
||||
@ -4014,7 +4085,7 @@ impl<I: DoubleEndedIterator, U, F> DoubleEndedIterator for FlatMap<I, U, F> wher
|
||||
///
|
||||
/// [`fuse()`]: trait.Iterator.html#method.fuse
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Fuse<I> {
|
||||
@ -4109,6 +4180,15 @@ pub struct Inspect<I, F> {
|
||||
f: F,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<I: fmt::Debug, F> fmt::Debug for Inspect<I, F> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Inspect")
|
||||
.field("iter", &self.iter)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Iterator, F> Inspect<I, F> where F: FnMut(&I::Item) {
|
||||
#[inline]
|
||||
fn do_inspect(&mut self, elt: Option<I::Item>) -> Option<I::Item> {
|
||||
@ -4272,7 +4352,7 @@ step_impl_no_between!(u64 i64);
|
||||
/// The resulting iterator handles overflow by stopping. The `A`
|
||||
/// parameter is the type being iterated over, while `R` is the range
|
||||
/// type (usually one of `std::ops::{Range, RangeFrom, RangeInclusive}`.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[unstable(feature = "step_by", reason = "recent addition",
|
||||
issue = "27741")]
|
||||
pub struct StepBy<A, R> {
|
||||
@ -4679,7 +4759,7 @@ impl<A: Step + One> DoubleEndedIterator for ops::RangeInclusive<A> where
|
||||
/// This `struct` is created by the [`repeat()`] function. See its documentation for more.
|
||||
///
|
||||
/// [`repeat()`]: fn.repeat.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Repeat<A> {
|
||||
element: A
|
||||
@ -4761,6 +4841,13 @@ pub fn repeat<T: Clone>(elt: T) -> Repeat<T> {
|
||||
#[stable(feature = "iter_empty", since = "1.2.0")]
|
||||
pub struct Empty<T>(marker::PhantomData<T>);
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<T> fmt::Debug for Empty<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.pad("Empty")
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "iter_empty", since = "1.2.0")]
|
||||
impl<T> Iterator for Empty<T> {
|
||||
type Item = T;
|
||||
@ -4830,7 +4917,7 @@ pub fn empty<T>() -> Empty<T> {
|
||||
/// This `struct` is created by the [`once()`] function. See its documentation for more.
|
||||
///
|
||||
/// [`once()`]: fn.once.html
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "iter_once", since = "1.2.0")]
|
||||
pub struct Once<T> {
|
||||
inner: ::option::IntoIter<T>
|
||||
|
@ -56,6 +56,7 @@
|
||||
|
||||
#![no_core]
|
||||
#![deny(missing_docs)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![cfg_attr(not(stage0), deny(warnings))]
|
||||
|
||||
#![feature(allow_internal_unstable)]
|
||||
|
@ -222,6 +222,7 @@ impl<'a> Part<'a> {
|
||||
|
||||
/// Formatted result containing one or more parts.
|
||||
/// This can be written to the byte buffer or converted to the allocated string.
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[derive(Clone)]
|
||||
pub struct Formatted<'a> {
|
||||
/// A byte slice representing a sign, either `""`, `"-"` or `"+"`.
|
||||
|
@ -763,7 +763,7 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
|
||||
// The Option Iterators
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
struct Item<A> {
|
||||
opt: Option<A>
|
||||
}
|
||||
@ -796,6 +796,7 @@ impl<A> ExactSizeIterator for Item<A> {}
|
||||
|
||||
/// An iterator over a reference of the contained item in an Option.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct Iter<'a, A: 'a> { inner: Item<&'a A> }
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -826,6 +827,7 @@ impl<'a, A> Clone for Iter<'a, A> {
|
||||
|
||||
/// An iterator over a mutable reference of the contained item in an Option.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct IterMut<'a, A: 'a> { inner: Item<&'a mut A> }
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -848,7 +850,7 @@ impl<'a, A> DoubleEndedIterator for IterMut<'a, A> {
|
||||
impl<'a, A> ExactSizeIterator for IterMut<'a, A> {}
|
||||
|
||||
/// An iterator over the item contained inside an Option.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<A> { inner: Item<A> }
|
||||
|
||||
|
@ -520,6 +520,7 @@ impl<T: ?Sized> PartialOrd for *mut T {
|
||||
/// modified without a unique path to the `Unique` reference. Useful
|
||||
/// for building abstractions like `Vec<T>` or `Box<T>`, which
|
||||
/// internally use raw pointers to manage the memory that they own.
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[unstable(feature = "unique", reason = "needs an RFC to flesh out design",
|
||||
issue = "27730")]
|
||||
pub struct Unique<T: ?Sized> {
|
||||
@ -592,6 +593,7 @@ impl<T> fmt::Pointer for Unique<T> {
|
||||
/// of this wrapper has shared ownership of the referent. Useful for
|
||||
/// building abstractions like `Rc<T>` or `Arc<T>`, which internally
|
||||
/// use raw pointers to manage the memory that they own.
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[unstable(feature = "shared", reason = "needs an RFC to flesh out design",
|
||||
issue = "27730")]
|
||||
pub struct Shared<T: ?Sized> {
|
||||
|
@ -59,6 +59,7 @@ use mem;
|
||||
/// println!("data pointer = {:?}, length = {}", repr.data, repr.len);
|
||||
/// ```
|
||||
#[repr(C)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Slice<T> {
|
||||
pub data: *const T,
|
||||
pub len: usize,
|
||||
@ -143,6 +144,7 @@ impl<T> Clone for Slice<T> {
|
||||
/// ```
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct TraitObject {
|
||||
pub data: *mut (),
|
||||
pub vtable: *mut (),
|
||||
|
@ -799,6 +799,7 @@ impl<'a, T, E> IntoIterator for &'a mut Result<T, E> {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// An iterator over a reference to the `Ok` variant of a `Result`.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Iter<'a, T: 'a> { inner: Option<&'a T> }
|
||||
|
||||
@ -830,6 +831,7 @@ impl<'a, T> Clone for Iter<'a, T> {
|
||||
}
|
||||
|
||||
/// An iterator over a mutable reference to the `Ok` variant of a `Result`.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IterMut<'a, T: 'a> { inner: Option<&'a mut T> }
|
||||
|
||||
@ -856,6 +858,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
|
||||
impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}
|
||||
|
||||
/// An iterator over the value in a `Ok` variant of a `Result`.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<T> { inner: Option<T> }
|
||||
|
||||
|
@ -38,6 +38,7 @@ use cmp::{Ordering, PartialEq, PartialOrd, Eq, Ord};
|
||||
use cmp::Ordering::{Less, Equal, Greater};
|
||||
use cmp;
|
||||
use default::Default;
|
||||
use fmt;
|
||||
use intrinsics::assume;
|
||||
use iter::*;
|
||||
use ops::{FnMut, self, Index};
|
||||
@ -877,6 +878,15 @@ pub struct Iter<'a, T: 'a> {
|
||||
_marker: marker::PhantomData<&'a T>,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("Iter")
|
||||
.field(&self.as_slice())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -925,6 +935,15 @@ pub struct IterMut<'a, T: 'a> {
|
||||
_marker: marker::PhantomData<&'a mut T>,
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("IterMut")
|
||||
.field(&make_slice!(self.ptr, self.end))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -980,6 +999,16 @@ pub struct Split<'a, T:'a, P> where P: FnMut(&T) -> bool {
|
||||
finished: bool
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for Split<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("Split")
|
||||
.field("v", &self.v)
|
||||
.field("finished", &self.finished)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, T, P> Clone for Split<'a, T, P> where P: Clone + FnMut(&T) -> bool {
|
||||
@ -1053,6 +1082,16 @@ pub struct SplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool {
|
||||
finished: bool
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SplitMut")
|
||||
.field("v", &self.v)
|
||||
.field("finished", &self.finished)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, P> SplitIter for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
#[inline]
|
||||
fn finish(&mut self) -> Option<&'a mut [T]> {
|
||||
@ -1127,6 +1166,7 @@ impl<'a, T, P> DoubleEndedIterator for SplitMut<'a, T, P> where
|
||||
/// An private iterator over subslices separated by elements that
|
||||
/// match a predicate function, splitting at most a fixed number of
|
||||
/// times.
|
||||
#[derive(Debug)]
|
||||
struct GenericSplitN<I> {
|
||||
iter: I,
|
||||
count: usize,
|
||||
@ -1162,6 +1202,15 @@ pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<Split<'a, T, P>>
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitN<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SplitN")
|
||||
.field("inner", &self.inner)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over subslices separated by elements that match a
|
||||
/// predicate function, limited to a given number of splits, starting
|
||||
/// from the end of the slice.
|
||||
@ -1170,6 +1219,15 @@ pub struct RSplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<Split<'a, T, P>>
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitN<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("RSplitN")
|
||||
.field("inner", &self.inner)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over subslices separated by elements that match a predicate
|
||||
/// function, limited to a given number of splits.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1177,6 +1235,15 @@ pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<SplitMut<'a, T, P>>
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitNMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SplitNMut")
|
||||
.field("inner", &self.inner)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over subslices separated by elements that match a
|
||||
/// predicate function, limited to a given number of splits, starting
|
||||
/// from the end of the slice.
|
||||
@ -1185,6 +1252,15 @@ pub struct RSplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<SplitMut<'a, T, P>>
|
||||
}
|
||||
|
||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitNMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("RSplitNMut")
|
||||
.field("inner", &self.inner)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! forward_iterator {
|
||||
($name:ident: $elem:ident, $iter_of:ty) => {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1212,6 +1288,7 @@ forward_iterator! { SplitNMut: T, &'a mut [T] }
|
||||
forward_iterator! { RSplitNMut: T, &'a mut [T] }
|
||||
|
||||
/// An iterator over overlapping subslices of length `size`.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Windows<'a, T:'a> {
|
||||
v: &'a [T],
|
||||
@ -1305,6 +1382,7 @@ impl<'a, T> ExactSizeIterator for Windows<'a, T> {}
|
||||
///
|
||||
/// When the slice len is not evenly divided by the chunk size, the last slice
|
||||
/// of the iteration will be the remainder.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Chunks<'a, T:'a> {
|
||||
v: &'a [T],
|
||||
@ -1405,6 +1483,7 @@ impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}
|
||||
/// An iterator over a slice in (non-overlapping) mutable chunks (`size`
|
||||
/// elements at a time). When the slice len is not evenly divided by the chunk
|
||||
/// size, the last slice of the iteration will be the remainder.
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct ChunksMut<'a, T:'a> {
|
||||
v: &'a mut [T],
|
||||
|
@ -323,7 +323,7 @@ Section: Iterators
|
||||
/// Created with the method [`chars()`].
|
||||
///
|
||||
/// [`chars()`]: ../../std/primitive.str.html#method.chars
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Chars<'a> {
|
||||
iter: slice::Iter<'a, u8>
|
||||
@ -468,7 +468,7 @@ impl<'a> Chars<'a> {
|
||||
}
|
||||
|
||||
/// Iterator for a string's characters and their byte offsets.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct CharIndices<'a> {
|
||||
front_offset: usize,
|
||||
@ -533,7 +533,7 @@ impl<'a> CharIndices<'a> {
|
||||
///
|
||||
/// [`bytes()`]: ../../std/primitive.str.html#method.bytes
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Bytes<'a>(Cloned<slice::Iter<'a, u8>>);
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -662,6 +662,17 @@ macro_rules! generate_pattern_iterators {
|
||||
$(#[$common_stability_attribute])*
|
||||
pub struct $forward_iterator<'a, P: Pattern<'a>>($internal_iterator<'a, P>);
|
||||
|
||||
$(#[$common_stability_attribute])*
|
||||
impl<'a, P: Pattern<'a>> fmt::Debug for $forward_iterator<'a, P>
|
||||
where P::Searcher: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple(stringify!($forward_iterator))
|
||||
.field(&self.0)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
$(#[$common_stability_attribute])*
|
||||
impl<'a, P: Pattern<'a>> Iterator for $forward_iterator<'a, P> {
|
||||
type Item = $iterty;
|
||||
@ -685,6 +696,17 @@ macro_rules! generate_pattern_iterators {
|
||||
$(#[$common_stability_attribute])*
|
||||
pub struct $reverse_iterator<'a, P: Pattern<'a>>($internal_iterator<'a, P>);
|
||||
|
||||
$(#[$common_stability_attribute])*
|
||||
impl<'a, P: Pattern<'a>> fmt::Debug for $reverse_iterator<'a, P>
|
||||
where P::Searcher: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple(stringify!($reverse_iterator))
|
||||
.field(&self.0)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
$(#[$common_stability_attribute])*
|
||||
impl<'a, P: Pattern<'a>> Iterator for $reverse_iterator<'a, P>
|
||||
where P::Searcher: ReverseSearcher<'a>
|
||||
@ -746,6 +768,7 @@ derive_pattern_clone!{
|
||||
clone SplitInternal
|
||||
with |s| SplitInternal { matcher: s.matcher.clone(), ..*s }
|
||||
}
|
||||
|
||||
struct SplitInternal<'a, P: Pattern<'a>> {
|
||||
start: usize,
|
||||
end: usize,
|
||||
@ -754,6 +777,18 @@ struct SplitInternal<'a, P: Pattern<'a>> {
|
||||
finished: bool,
|
||||
}
|
||||
|
||||
impl<'a, P: Pattern<'a>> fmt::Debug for SplitInternal<'a, P> where P::Searcher: fmt::Debug {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SplitInternal")
|
||||
.field("start", &self.start)
|
||||
.field("end", &self.end)
|
||||
.field("matcher", &self.matcher)
|
||||
.field("allow_trailing_empty", &self.allow_trailing_empty)
|
||||
.field("finished", &self.finished)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
|
||||
#[inline]
|
||||
fn get_end(&mut self) -> Option<&'a str> {
|
||||
@ -852,12 +887,22 @@ derive_pattern_clone!{
|
||||
clone SplitNInternal
|
||||
with |s| SplitNInternal { iter: s.iter.clone(), ..*s }
|
||||
}
|
||||
|
||||
struct SplitNInternal<'a, P: Pattern<'a>> {
|
||||
iter: SplitInternal<'a, P>,
|
||||
/// The number of splits remaining
|
||||
count: usize,
|
||||
}
|
||||
|
||||
impl<'a, P: Pattern<'a>> fmt::Debug for SplitNInternal<'a, P> where P::Searcher: fmt::Debug {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("SplitNInternal")
|
||||
.field("iter", &self.iter)
|
||||
.field("count", &self.count)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, P: Pattern<'a>> SplitNInternal<'a, P> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a str> {
|
||||
@ -902,8 +947,17 @@ derive_pattern_clone!{
|
||||
clone MatchIndicesInternal
|
||||
with |s| MatchIndicesInternal(s.0.clone())
|
||||
}
|
||||
|
||||
struct MatchIndicesInternal<'a, P: Pattern<'a>>(P::Searcher);
|
||||
|
||||
impl<'a, P: Pattern<'a>> fmt::Debug for MatchIndicesInternal<'a, P> where P::Searcher: fmt::Debug {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("MatchIndicesInternal")
|
||||
.field(&self.0)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<(usize, &'a str)> {
|
||||
@ -944,8 +998,17 @@ derive_pattern_clone!{
|
||||
clone MatchesInternal
|
||||
with |s| MatchesInternal(s.0.clone())
|
||||
}
|
||||
|
||||
struct MatchesInternal<'a, P: Pattern<'a>>(P::Searcher);
|
||||
|
||||
impl<'a, P: Pattern<'a>> fmt::Debug for MatchesInternal<'a, P> where P::Searcher: fmt::Debug {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("MatchesInternal")
|
||||
.field(&self.0)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a str> {
|
||||
@ -988,7 +1051,7 @@ generate_pattern_iterators! {
|
||||
///
|
||||
/// [`lines()`]: ../../std/primitive.str.html#method.lines
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Lines<'a>(Map<SplitTerminator<'a, char>, LinesAnyMap>);
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1019,7 +1082,7 @@ impl<'a> DoubleEndedIterator for Lines<'a> {
|
||||
/// [`lines_any()`]: ../../std/primitive.str.html#method.lines_any
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.4.0", reason = "use lines()/Lines instead now")]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[allow(deprecated)]
|
||||
pub struct LinesAny<'a>(Lines<'a>);
|
||||
|
||||
@ -1242,7 +1305,7 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
|
||||
/// Struct that contains a `char` and the index of the first byte of
|
||||
/// the next `char` in a string. This can be used as a data structure
|
||||
/// for iterating over the UTF-8 bytes of a string.
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[unstable(feature = "str_char",
|
||||
reason = "existence of this struct is uncertain as it is frequently \
|
||||
able to be replaced with char.len_utf8() and/or \
|
||||
|
@ -20,6 +20,7 @@
|
||||
use prelude::v1::*;
|
||||
|
||||
use cmp;
|
||||
use fmt;
|
||||
use usize;
|
||||
|
||||
// Pattern
|
||||
@ -275,7 +276,7 @@ impl<'a> CharEq for &'a [char] {
|
||||
|
||||
struct CharEqPattern<C: CharEq>(C);
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
struct CharEqSearcher<'a, C: CharEq> {
|
||||
char_eq: C,
|
||||
haystack: &'a str,
|
||||
@ -415,7 +416,7 @@ macro_rules! searcher_methods {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Associated type for `<char as Pattern<'a>>::Searcher`.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CharSearcher<'a>(<CharEqPattern<char> as Pattern<'a>>::Searcher);
|
||||
|
||||
unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
|
||||
@ -440,7 +441,7 @@ impl<'a> Pattern<'a> for char {
|
||||
// Todo: Change / Remove due to ambiguity in meaning.
|
||||
|
||||
/// Associated type for `<&[char] as Pattern<'a>>::Searcher`.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CharSliceSearcher<'a, 'b>(<CharEqPattern<&'b [char]> as Pattern<'a>>::Searcher);
|
||||
|
||||
unsafe impl<'a, 'b> Searcher<'a> for CharSliceSearcher<'a, 'b> {
|
||||
@ -467,6 +468,17 @@ impl<'a, 'b> Pattern<'a> for &'b [char] {
|
||||
pub struct CharPredicateSearcher<'a, F>(<CharEqPattern<F> as Pattern<'a>>::Searcher)
|
||||
where F: FnMut(char) -> bool;
|
||||
|
||||
impl<'a, F> fmt::Debug for CharPredicateSearcher<'a, F>
|
||||
where F: FnMut(char) -> bool
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("CharPredicateSearcher")
|
||||
.field("haystack", &self.0.haystack)
|
||||
.field("char_indices", &self.0.char_indices)
|
||||
.field("ascii_only", &self.0.ascii_only)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
unsafe impl<'a, F> Searcher<'a> for CharPredicateSearcher<'a, F>
|
||||
where F: FnMut(char) -> bool
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
|
||||
/// Rust's memory orderings are [the same as
|
||||
/// LLVM's](http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations).
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum Ordering {
|
||||
/// No ordering constraints, only atomic operations. Corresponds to LLVM's
|
||||
/// `Monotonic` ordering.
|
||||
|
Loading…
Reference in New Issue
Block a user