about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-17 09:11:17 +0100
committerGitHub <noreply@github.com>2025-01-17 09:11:17 +0100
commite2d14ec701089b313ce07cf7253663c76b81652f (patch)
treed67688ae54aa52014a0928744fc3a61343de88a2 /src/doc
parent0c2c096e1ac471b0c34629f9820a7cb1e6d4695d (diff)
parent9397d133f683070863029552313b5e083398bf42 (diff)
downloadrust-e2d14ec701089b313ce07cf7253663c76b81652f.tar.gz
rust-e2d14ec701089b313ce07cf7253663c76b81652f.zip
Rollup merge of #131806 - lolbinarycat:rustdoc-search-all-is-func, r=notriddle
Treat other items as functions for the purpose of type-based search

specifically, constants and statics are nullary functions, and struct fields are unary functions.

fixes #130204

r? ``@notriddle``
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/rustdoc/src/read-documentation/search.md14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/doc/rustdoc/src/read-documentation/search.md b/src/doc/rustdoc/src/read-documentation/search.md
index e06dcdb7ed2..bace2f5f953 100644
--- a/src/doc/rustdoc/src/read-documentation/search.md
+++ b/src/doc/rustdoc/src/read-documentation/search.md
@@ -52,9 +52,10 @@ methods on the allocator or free functions.
 
 [`Layout`]: ../../alloc/index.html?search=Layout&filter-crate=alloc
 
-## Searching By Type Signature for functions
+## Searching By Type Signature
 
 If you know more specifically what the function you want to look at does,
+or you want to know how to get from one type to another,
 Rustdoc can search by more than one type at once in the parameters and return
 value. Multiple parameters are separated by `,` commas, and the return value
 is written with after a `->` arrow.
@@ -86,6 +87,17 @@ the standard library and functions that are included in the results list:
 [iterasslice]: ../../std/vec/struct.Vec.html?search=vec%3A%3Aintoiter<T>%20->%20[T]&filter-crate=std
 [iterreduce]: ../../std/index.html?search=iterator<T>%2C%20fnmut%20->%20T&filter-crate=std
 
+### Non-functions in type-based search
+Certain items that are not functions are treated as though they
+were a semantically equivelent function.
+
+For example, struct fields are treated as though they were getter methods.
+This means that a search for `CpuidResult -> u32` will show
+the `CpuidResult::eax` field in the results.
+
+Additionally, `const` and `static` items are treated as nullary functions,
+so `-> u32` will match `u32::MAX`.
+
 ### How type-based search works
 
 In a complex type-based search, Rustdoc always treats every item's name as literal.