4

rustdoc: search for slices and arrays by type with `[]` by notriddle · Pull Requ...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/111958
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for slices and arrays. Part of #60485

Function signature searches already support arrays and slices. The explicit name primitive:slice<u8> and primitive:array<u8> can be used to match a slice or array of bytes, while square brackets [u8] will match either one. Empty square brackets, [], will match any slice regardless of what it contains.

Preview:

Motivation:

When type-based search was first landed, it was directly described as "incomplete". Here's a comment from the discussion thread:

This is looking really great, nice work! I can think of a number of cases that aren't quite covered by this, but I feel like this is a great improvement regardless and it can always be iterated on so I'm fine landing with a few known cases where it may not work :)

Filling out the missing functionality is going to mean adding support for more of Rust's type expression syntax, such as slices (in this PR), tuples, references, raw pointers, function pointers, and generics.

There does seem to be demand for this sort of thing, such as this Discord message expressing regret at rustdoc not supporting tuples in search queries.

tgross35 reacted with thumbs up emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK