Skip to content

impl Default for ExitStatus #158

Closed
Closed
@ijackson

Description

@ijackson

Proposal

Problem statement

It is not possible for code outside std to portably create an ExitStatus without actually running a process.

Motivation, use-cases

In some cases it might be convenient to use Option<ExitStatus>; but ExitStatus is already kind of option-ish in that it can represent an error, or no error.

It is IMO not reasonable to have a type that a user can mostly-portably create, but to require a user to run a dummy process to do so. This type can already be non-portably constructed on Unix and Windows via ExitStatusExt.

Solution sketches

The obvious-to-me answer is to impl Default for ExitStatus.

I did that in rust-lang/rust#106425 and am now belatedly making this ACP.

A consequence is that ExitStatus now becomes inhabited even on platforms without subprocesses. This seems reasonable.

Links and related work

See also the tracking issue for thec currently-unstable ExitStatusError, rust-lang/rust#84908. I'm postponing addressing the same question for ExitStatusError, but it should be considered before stabilisation.

What happens now?

This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.

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