Skip to content

doc: more consistent comments about vector types. #11796

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

Closed
wants to merge 1 commit into from
Closed

doc: more consistent comments about vector types. #11796

wants to merge 1 commit into from

Conversation

lecram
Copy link
Contributor

@lecram lecram commented Jan 25, 2014

No description provided.

@brson
Copy link
Contributor

brson commented Jan 26, 2014

@lecram Hm, I wonder what the balance is of snippets that use backticks to those that don't. I'm a markdown junkie so my inclination is that, yes, we should always use them both in code-in-comments and in code-in-comments-in-examples. I'd be curious about what others think though.

@brson
Copy link
Contributor

brson commented Jan 26, 2014

@huonw concurs.

@lecram
Copy link
Contributor Author

lecram commented Jan 26, 2014

There are about the same amount of snippets on the tutorial that uses backticks for code-in-comments and that don't. Something like ten of each. Should file names in comments be enclosed in backticks too?

@adrientetar
Copy link
Contributor

Agreed with @brson. Comments are text (semantically-wise) and backticks separate code elements from text.

@brson
Copy link
Contributor

brson commented Feb 1, 2014

@lecram I lean toward backtick filenames too.

@lecram
Copy link
Contributor Author

lecram commented Feb 2, 2014

Thanks for the feedback.

Please note that this Pull Request is not about backticks. For this reason I created a separate PR, trying to solve the backticks matter (see #11996).

Specifically, this Pull Request is about the confusion that may arise from statements like this one:

Slices have their type written as &[int]

Reading that in an official tutorial, one might think that there is some special relation between slices and the type int. I'm proposing the use of the placeholder Type in such instances. Note that this placeholder is already used in the comment about fixed-size vector (hence the title of this PR).

bors added a commit that referenced this pull request Feb 2, 2014
This Pull Request aims to add backticks to all instances of code inside comments in snippets present in tutorial.md. It also includes backticks for filenames in the same conditions. See #11796 for motivation.
@alexcrichton
Copy link
Member

Closing due to a lack of activity, but feel free to reopen with a rebase!

flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 14, 2024
Closes rust-lang/rust-clippy#10118

This lint checks `map_or` method calls to check if they can be
consolidated down to something simpler and/or more readable.

For example, the code
```rs
let x = Some(5);
x.map_or(false, |n| n == 5)
```

can be rewritten as
```rs
let x = Some(5);
x == Some(5)
```

In addition, when the closure is more complex, the code can be altered
from, say,
```rs
let x = Ok::<Vec<i32>, i32>(vec![5]);
x.map_or(false, |n| n == [5])
```
into
```rs
let x = Ok::<Vec<i32>, i32>(vec![5]);
x.is_some_and(|n| n == [5])
```

This lint also considers cases where the `map_or` can be chained with
other method calls, and accommodates accordingly by adding extra
parentheses as needed to the suggestion.

changelog: add new lint `unnecessary_map_or`
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