Skip to content

memory pre-allocation is not correct for multi-byte separators #7

@szabgab

Description

@szabgab

This is not a critical issue as Rust will move the string to a new place when the old one does not have enough space to contain the whole string, but if the crate already does some memory pre-allocation it should probably allocate enough for multi-byte separators. (e.g. an emoji)

The issue can be observed by adding a println!("Allocated {}", result.capacity()); on line 12 of src/display.rs and then also printing the len() of the string that is returned by separate_by_policy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions