Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd examples for Ord and PartialOrd traits in std docs #15253
Comments
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
I missed that total order has
Note: I'm not remarking about the accuracy or precision of the definition. Just ease of comprehension. |
This comment has been minimized.
This comment has been minimized.
|
It doesn't have anything to do with the values contained in a specific array. As with all traits, it's a property of types. |
This comment has been minimized.
This comment has been minimized.
|
The type must fit with this |
steveklabnik
added
the
A-docs
label
Jul 8, 2014
This comment has been minimized.
This comment has been minimized.
|
A total ordering is a property of a type, not an array. |
This comment has been minimized.
This comment has been minimized.
|
@sfackler explained how my examples were ambiguous and I have used his explanation/examples to revise the example below. @thestinger, his explanation also also explained your comments which I didn't understand before. // A `type` which forms a total order is completely sortable
// `i32` forms a Total Order
let _entirelySortable = [1i32, -1, 7, 3, 5, 9]; // Sortable because `i32` is
// `f32` does not form a Total Order
let _partiallySortable1 = [1.0f32, -1.0, 7.0, std::f32::NAN];
// NAN's sorting order is undefined making this `type` unsortable
// (Is NAN before or after 3?)
// Still unsortable because `f32` supports NAN
let _partiallySortable2 = [1.0f32, -1.0, 7.0, 14.2]; // Also, not a total orderMy issue with the Ord page is without understanding Total order, it's difficult to know what it's talking about without thinking through that math example. If you look at #15217 where they assume people don't know the
Into: "Ah! This type has one unique sorting order with no exceptions! Obviously, if there is an exception, I have to use PartialOrd instead". The definition is certainly precise but it should be more readable (or have an example). Also, the range notation is much simpler and obvious once you know it. The issue with PartialOrd is that knowing what to use it for depends on knowing what Ord cannot be used for. I think making Ord more readable would be helpful. I grouped them together because they are related and an example in one could possibly be duplicated in the other because it is probably still pertinent. [EDIT] |
This comment has been minimized.
This comment has been minimized.
|
I don't think this is particularly actionable, or at least, any more than a general "most docs can be improved" kind of way. While they may be short, they are accurate, so I'm going to close this. Concrete improvements to any docs, including these docs, are welcome. |
mdinger commentedJun 29, 2014
Trait Ord and PartialOrd have cryptic explanations. An example would be helpful.
I thought these would be valid examples:
@steveklabnik You asked to be CCed on documentation bugs