Skip to content

Conversation

@RPG-Alex
Copy link
Contributor

Tighten linting; fix rustdoc warnings across feature gates

I continued using stricter linting and found several odd cases in tests and
examples, along with rustdoc warnings triggered by feature-gated items.

This commit cleans up those warnings by:

  • adjusting tests to avoid clippy false positives under -D warnings
  • removing unused generics and ambiguous empty vec initializers
  • fixing rustdoc links via feature-gated doc attributes rather than
    linking to non-exported items

All tests are still passing.

Clippy still warns about the use of 1..-1 as an empty range; this appears
intentional in ndarray slicing semantics, so I’ve left it unchanged for now.

Please review the rustdoc changes that rely on feature-gated documentation.

{
/// Checks if the permutation is correct
pub fn from_indices(v: Vec<usize>) -> Result<Self, ()>
pub fn from_indices(v: Vec<usize>) -> Option<Self>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that you didn't "change" anything, this is mostly reformatting, but this one here is different. This is a public function, so there might be several callers out there who will be surprised by this API change.

I'm not against changing it. I guess a Result<X, ()> is functionally equivalent to an Option<X>. I just want to highlight this change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally I'm ok with this, but I'm glad you brought it up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if you would like me to revert it.

https://effective-rust.com/transform.html

I think its better to return the Option and makes the signature clearer, and should require minimal refactoring downstream. While Result<T, ()> is basically the same functionally as Option<T> it doesn't covey the intent clearly. Usually Result is reserved for situations like where there is an expected value or an error variant and allows for propagating errors with ?.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed that it's the better practice, just good for us to keep in mind it will have to be a breaking change release.

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.

3 participants