Skip to content

Add Default implementation for &CStr, CString, Path#32990

Merged
bors merged 1 commit into
rust-lang:masterfrom
tbu-:pr_more_defaults_cstr_path
May 5, 2016
Merged

Add Default implementation for &CStr, CString, Path#32990
bors merged 1 commit into
rust-lang:masterfrom
tbu-:pr_more_defaults_cstr_path

Conversation

@tbu-

@tbu- tbu- commented Apr 15, 2016

Copy link
Copy Markdown
Contributor

No description provided.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@tbu-

tbu- commented Apr 15, 2016

Copy link
Copy Markdown
Contributor Author

Split off from #32785. Some motivation: #32785 (comment).

@alexcrichton

Copy link
Copy Markdown
Member

CString seems fine to me personally as CString::new is the "clear and obvious constructor", the others seem conventionally fine but not perhaps well motivated.

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Apr 15, 2016
@tbu-

tbu- commented Apr 15, 2016

Copy link
Copy Markdown
Contributor Author

"" is the default value for &str, I'd argue that the equivalent value should be the default value for &CStr.

Comment thread src/libstd/ffi/c_str.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just hit 1.8.0 release, so it becomes since = 1.10.0 (if you could confirm @alexcrichton?).

@nagisa

nagisa commented Apr 15, 2016

Copy link
Copy Markdown
Member

I’m not sure about "" as the default path. You can’t even do anything sensible with it (at least on linux), other than join to other paths.

@tbu-

tbu- commented Apr 15, 2016

Copy link
Copy Markdown
Contributor Author

Dunno, maybe base.join(config_option.unwrap_or_default())

@nagisa

nagisa commented Apr 15, 2016

Copy link
Copy Markdown
Member

@tbu- for that purpose an equivalent of UNIX’s . has the same behaviour.

EDIT: in other words, I think this is too much a bikesheddable part to be included without an RFC.

@tbu-

tbu- commented Apr 16, 2016

Copy link
Copy Markdown
Contributor Author

@nagisa Not for verbatim paths on Windows.

@aturon

aturon commented Apr 19, 2016

Copy link
Copy Markdown
Contributor

I'm fine with the CString-related defaults, but agree that the one for Path is probably more problematic than it's worth.

@brson brson added the relnotes Marks issues that should be documented in the release notes of the next release. label May 4, 2016
@alexcrichton

Copy link
Copy Markdown
Member

The libs team discussed this PR during triage today and the conclusion was that the Default implementations for CStr and CString seem fine, but as mentioned previously we'd prefer that Path were left out for now.

Could you make those changes @tbu- and I'll r+? Thanks again for the PR!

@tbu- tbu- force-pushed the pr_more_defaults_cstr_path branch from 44e67d0 to 5efe083 Compare May 5, 2016 08:57
@tbu-

tbu- commented May 5, 2016

Copy link
Copy Markdown
Contributor Author

@alexcrichton Changed.

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+ 5efe083

@bors

bors commented May 5, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 5efe083 with merge 77987ba...

bors added a commit that referenced this pull request May 5, 2016
Add `Default` implementation for `&CStr`, `CString`, `Path`
@bors bors merged commit 5efe083 into rust-lang:master May 5, 2016
steveklabnik added a commit that referenced this pull request Jul 7, 2016
Path was not actually given a default impl in #32990, even though the PR title said it did.

r? @brson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes Marks issues that should be documented in the release notes of the next release. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants