Skip to content

str::as_str but for CStr, OsStr, Path, and [T] #643

@GrigorenkoPV

Description

@GrigorenkoPV

Proposal

Add CStr::as_c_str, OsStr::as_os_str, Path::as_path, [T]::as_slice, and [T]::as_mut_slice, analogous to str::as_str (rust-lang/rust#130366) to aid dereferencing Box<CStr/OsStr/...> without CString, OsString, ... being the only ones with the convenient .as_thing() method.

Background

str::as_str was proposed by t-libs-api in rust-lang/rust#129550 (comment) as a response to a PR adding Box<str>::as_str.

The idea of analogous additions for other "slicy" types was brought up in rust-lang/rust#130366 (comment)

Solution sketch

rust-lang/rust#145933

Questions

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions