Skip to content

OpenOptions: create() and create_new() are flip flopped #69254

Closed
@JesterOrNot

Description

@JesterOrNot

I tried this code:

OpenOptions::new()
        .write(true)
        .create(true)
        .open(&args.target)

and it creates a file even if it already exists

OpenOptions::new()
        .write(true)
        .create_new(true)
        .open(&args.target)

This code creates a file only if the file does not exist

But look at the docs
For create()
image

For create_new()
image

I expected to see this happen: explanation
The functions to match their docs
Instead, this happened: explanation
They each do what the other is described to do

Meta

rustc --version --verbose:

rustc 1.41.0 (5e1a79984 2020-01-27)
binary: rustc
commit-hash: 5e1a799842ba6ed4a57e91f7ab9435947482f7d8
commit-date: 2020-01-27
host: x86_64-unknown-linux-gnu
release: 1.41.0
LLVM version: 9.0
Backtrace

gitpod /workspace/nushell $ RUST_BACKTRACE=1 cargo build
   Compiling nu v0.9.1 (/workspace/nushell)
    Finished dev [unoptimized + debuginfo] target(s) in 26.35s

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions