Skip to content

read_metrics_one_file_by_end_time do not work as expected because read_line function reads \n into the buffer #145

@flearc

Description

@flearc

From official doc, the read_line function read \n to the buffer as well.

use std::io::{self, BufRead};

let mut cursor = io::Cursor::new(b"foo\nbar");
let mut buf = String::new();

// cursor is at 'f'
let num_bytes = cursor.read_line(&mut buf)
    .expect("reading from cursor won't fail");
assert_eq!(num_bytes, 4);
assert_eq!(buf, "foo\n");
buf.clear();

\n will lead to failures in functions like read_metrics_one_file_by_end_time.

Consider use the lines function in BufReader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions