rustdoc: Indicate struct can be created + fn#107926
rustdoc: Indicate struct can be created + fn#107926mustakimali wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jsha (or someone else) soon. Please see the contribution instructions for more information. |
|
Didn't mean to send the PR now, It's a draft PR :( |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
☔ The latest upstream changes (presumably #108228) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@mustakimali any updates? |
When typing `MyType::` the completion items' order could be re-ordered based on how likely we want to select those: * Constructors: `new` like functions to be able to create the type, * Builder Methods: any builder methods available, * Constructors that take args: Any other function that creates `Self`, * Regular methods & associated functions (no change there)  In this photo, the order is: * `new` constructor is first * `new_builder` second is a builder method * `aaaanew` is a constructor that takes arguments, is third and is irrespective of its alphabetical order among names. I've dropped my previous idea of highlighting these functions in the rustdoc (rust-lang/rust#107926)
When typing `MyType::` the completion items' order could be re-ordered based on how likely we want to select those: * Constructors: `new` like functions to be able to create the type, * Builder Methods: any builder methods available, * Constructors that take args: Any other function that creates `Self`, * Regular methods & associated functions (no change there)  In this photo, the order is: * `new` constructor is first * `new_builder` second is a builder method * `aaaanew` is a constructor that takes arguments, is third and is irrespective of its alphabetical order among names. I've dropped my previous idea of highlighting these functions in the rustdoc (rust-lang/rust#107926)
feat: completion list suggests constructor like & builder methods first When typing `MyType::` the completion items' order could be re-ordered based on how likely we want to select those: * Constructors: `new` like functions to be able to create the type, * Constructors that take args: Any other function that creates `Self`, * Builder Methods: any builder methods available, * Regular methods & associated functions (no change there)  In this photo, the order is: * `new` constructor is first * `new_builder` second is a builder method * `aaaanew` is a constructor that takes arguments, is third and is irrespective of its alphabetical order among names. --- Another Example using actix `HttpServer` shows preferring constructor without `self` arg first (the `new` method)   I've dropped my previous idea of highlighting these functions in the rustdoc (rust-lang/rust#107926)
@Dylan-DPC I wasn't sure if highlighting in the doc would be useful. So I quickly lost motivation and implemented something similar in the |
|
This would be really useful in rustdoc. Having something for this in rust-analyzer is really not a substitute for this. When you are reading the documentation of a type sometimes it is difficult to find out, how one should actually create an instance of that type from the documentation. Having a separate |
Visual hint to indicate the
Structthat can be created from outside as well as highlight the functions that can be used as well (function that does not takeselfand returns the type,OptionorResult)Signed-off-by: Mohammad Mustakim Ali mustakimali@users.noreply.github.com