Skip to content

as_mut_str() unsound? #437

@Enyium

Description

@Enyium

Isn't this unsound?

let mut s = CompactString::const_new("test");
s.as_mut_str().make_ascii_uppercase();

It mutates a &'static str without unsafe!

Possible solutions:

  • Make as_mut_str() return Option<&mut str> (similar to as_static_str()).
  • Make as_mut_str() unsafe.

Other methods may also be affected. Related issue: #326.

Even if this issue rests for a while, the documentation should warn about this.

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