Expand description
Type rendering utilities for converting rustdoc types to string representations.
This module provides the TypeRenderer struct to convert the complex type
structures from rustdoc JSON into human-readable Rust type syntax. These
rendered strings are used in the generated markdown documentation.
§Overview
Rustdoc JSON represents types as a tree structure (the Type enum). The
TypeRenderer walks that tree and produces the string representation
you’d write in code.
§Usage
ⓘ
let renderer = TypeRenderer::new(&krate);
let type_string = renderer.render_type(&some_type);
let generics = renderer.render_generics(&generic_params);§Example Transformations
| Rustdoc Type | Rendered String |
|---|---|
Type::Primitive("u32") | "u32" |
Type::BorrowedRef { lifetime: Some("'a"), is_mutable: true, type_: ... } | "&'a mut T" |
Type::ResolvedPath { path: "Vec", args: ... } | "Vec<T>" |
§Performance
Uses Cow<str> to avoid allocations for simple types like primitives,
generics, and inferred types. Complex types that require string building
return owned strings.
Structs§
- Type
Renderer - Type renderer for converting rustdoc types to Rust syntax strings.