1
Fork 0

fix(rustdoc): generics search

This commit adds a test case for generics, re-adds generics data
to the search index, and tweaks function indexing to use less space in JSON.

This reverts commit 14ca89446c.
This commit is contained in:
Michael Howell 2021-06-26 12:00:26 -07:00
parent 3cb1c11340
commit cedd2425b6
8 changed files with 191 additions and 19 deletions

View file

@ -96,6 +96,7 @@ crate struct IndexItem {
#[derive(Debug)]
crate struct RenderType {
name: Option<String>,
generics: Option<Vec<String>>,
}
/// Full type of functions/methods in the search index.
@ -149,7 +150,13 @@ impl Serialize for TypeWithKind {
where
S: Serializer,
{
(&self.ty.name, self.kind).serialize(serializer)
let mut seq = serializer.serialize_seq(None)?;
seq.serialize_element(&self.ty.name)?;
seq.serialize_element(&self.kind)?;
if let Some(generics) = &self.ty.generics {
seq.serialize_element(generics)?;
}
seq.end()
}
}