Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add primitive doc for () #15321

Merged
merged 2 commits into from
Jul 4, 2014
Merged

Add primitive doc for () #15321

merged 2 commits into from
Jul 4, 2014

Conversation

huonw
Copy link
Member

@huonw huonw commented Jul 2, 2014

This adds a primitive page for () like http://doc.rust-lang.org/master/std/uint/primitive.uint.html .

I would prefer the modules to be std::tuple::unit, but rustdoc only searches at the top level (filed as #15320).

Quick poll on IRC suggested that unit was the preferred name for ().
//! fn long() -> () {}
//!
//! fn short() {}
//! ```
Copy link
Member

Choose a reason for hiding this comment

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

Maybe mention ; too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a paragraph below; what do you think?

@alexcrichton
Copy link
Member

This would make for the second public-facing, documentation-only module (other one being std::bool).

I would prefer to have these both not be publicly usable modules and only accessible from the documentation, but alas! I need to go and write some more rustdoc logic!


#![doc(primitive = "unit")]

//! The `()` type, sometimes called "nil" or "unit".
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps invert the mention of nil/unit? (just to emphasize that unit is the conventional naming).

@alexcrichton
Copy link
Member

r=me with or without the two comments above, thanks!

//! fn short() {}
//! ```
//!
//! The semicolon `;` can be used to discard a result of statement at
Copy link
Member

Choose a reason for hiding this comment

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

It's the result of an expression, not a statement.

Copy link
Member Author

Choose a reason for hiding this comment

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

(1;) is not valid, i.e. a ;'d expression has to be in statement position.

Copy link
Member

Choose a reason for hiding this comment

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

Ahhh I see what you're saying. Also, the phrasing is awkward, should probably be "can be used to discard the result of a statement at".

What I was thinking of was that ; discards the results of the 1, which is an expression, and gives () instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, yes, the phrasing is horrible. I edited two sentences into one without actually making them connect properly...

Yeah, that's a good point, I think saying "end of some block" specifically is enough to change statement to expression, so I'll do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Is this better?

bors added a commit that referenced this pull request Jul 4, 2014
This adds a primitive page for () like http://doc.rust-lang.org/master/std/uint/primitive.uint.html .

I would prefer the modules to be `std::tuple::unit`, but rustdoc only searches at the top level (filed as #15320).
@bors bors closed this Jul 4, 2014
@bors bors merged commit 7c92735 into rust-lang:master Jul 4, 2014
//!
//! The semicolon `;` can be used to discard the result of an
//! expression at the end of a block, making the expression (and thus
//! the block) evaluate to `()`. For example,
Copy link
Member

Choose a reason for hiding this comment

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

I've been using For example: rather than For example,, I wonder which is better?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, don't know.

(It's mainly just a habit I have from mathematics, where even an "broken out" equation is normally written to be a natural part of the sentence it's in

Hence, we've proven that

a + 2 = 3

where a = 1.

This may not be the style we want for Rust's docs.)

@huonw huonw deleted the nil-prim branch July 11, 2014 05:54
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 24, 2023
Normalize expected ty in call arguments

fix rust-lang#15321

I'm not sure if we should do this, or add a normalize in the beginning of `infer_expr_inner`, or somewhere else. r? `@lowr`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants