Skip to content

Create a string type that represents either ~str or &'static str #6874

Description

@brson

There are a few places in the runtime where it is nice to pass strings around to identify things, and many but not all the strings are known statically. Examples include failure messages, logging messages, task names, test names, condition and error messages.

Failure already does this using the FailureWithCause trait, which could be refactored into a single function over this string type. std::test does similar optimizations.

Activity

  1. catamorphism commented on Sep 23, 2013

    @catamorphism
    Contributor

    A "String" trait, perhaps?

  2. alexcrichton commented on Sep 23, 2013

    @alexcrichton
    Member

    This is actually implemented as SendStr in src/libstd/send_str.rs, added in 76c3e8a, closing

  3. added a commit that references this issue on Mar 11, 2021
  4. added a commit that references this issue on Mar 25, 2021
    52c25e9
  5. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions