Skip to content

Incorrect upper bound for size_hint of char::DecodeUtf16 #88762

Closed
@steffahn

Description

@steffahn
use std::char::decode_utf16;

fn main() {
    let x = [0xD834, 0x006d];
    let mut d = decode_utf16(x);
    d.next();
    let (_, u) = d.size_hint();
    let c = d.count();
    println!("upper bound: {:?}, actual length {}", u, c);
    assert!(u.unwrap() >= c);
}
   Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 1.04s
     Running `target/debug/playground`
thread 'main' panicked at 'assertion failed: u.unwrap() >= c', src/main.rs:10:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Standard Output

upper bound: Some(0), actual length 1

(playground)

@rustbot label T-libs, A-iterators

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-iteratorsArea: IteratorsC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions