Add PeekableIterator trait by wmstack · Pull Request #144935 · rust-lang/rust (original) (raw)

   |
18 |     }
   |      ^ help: add `;` here
19 |
20 |     u32::from_str_radix(c.as_str(), base).unwrap()
   |     --- unexpected token

error[E0308]: mismatched types
  --> library/core/src/iter/traits/peekable.rs:45:32
   |
10 |     let base = if c.next_if_eq(&"0").is_some() {
   |                     ---------- ^^^^ expected `&char`, found `&&str`
   |                     |
   |                     arguments to this method are incorrect
   |
   = note: expected reference `&char`
              found reference `&&'static str`
note: method defined here
  --> /checkout/library/core/src/iter/traits/peekable.rs:70:8
   |
70 |     fn next_if_eq<T>(&mut self, expected: &T) -> Option<Self::Item>
   |        ^^^^^^^^^^

error[E0277]: the trait bound `&char: Pattern` is not satisfied
    --> library/core/src/iter/traits/peekable.rs:46:44
     |
  11 |         match c.next_if(|c| "oxb".contains(c)) {
     |                                   -------- ^ the trait `Fn(char)` is not implemented for `char`
     |                                   |
     |                                   required by a bound introduced by this call
     |
     = note: required for `&char` to implement `FnOnce(char)`
     = note: required for `&char` to implement `Pattern`
note: required by a bound in `core::str::<impl str>::contains`
    --> /checkout/library/core/src/str/mod.rs:1340:24
     |
1340 |     pub fn contains<P: Pattern>(&self, pat: P) -> bool {
     |                        ^^^^^^^ required by this bound in `core::str::<impl str>::contains`
help: consider dereferencing here
     |
  11 |         match c.next_if(|c| "oxb".contains(*c)) {
     |                                            +

error[E0308]: mismatched types
  --> library/core/src/iter/traits/peekable.rs:47:18
   |
11 |         match c.next_if(|c| "oxb".contains(c)) {
   |               -------------------------------- this expression has type `Option<char>`
12 |             Some("x") => 16,
   |                  ^^^ expected `char`, found `&str`
   |
help: if you meant to write a `char` literal, use single quotes
   |
12 -             Some("x") => 16,
12 +             Some('x') => 16,
   |

error[E0308]: mismatched types
  --> library/core/src/iter/traits/peekable.rs:48:18
   |
11 |         match c.next_if(|c| "oxb".contains(c)) {
   |               -------------------------------- this expression has type `Option<char>`
12 |             Some("x") => 16,
13 |             Some("b") => 2,
   |                  ^^^ expected `char`, found `&str`
   |
help: if you meant to write a `char` literal, use single quotes
   |
13 -             Some("b") => 2,
13 +             Some('b') => 2,
   |

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0277, E0308.
---
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: rust_out::main::_doctest_main_library_core_src_iter_traits_peekable_rs_9_0
   5: rust_out::main
   6: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- library/core/src/iter/traits/peekable.rs - iter::traits::peekable::PeekableIterator::peek_with (line 9) stdout end ----