Skip to content

Commit 750ac69

Browse files
committed
Add documentation to src/pretty.rs
1 parent aaa2ac8 commit 750ac69

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/pretty.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
//! A set of utilities for pretty-printing various data structures.
2+
//!
3+
//! It uses the [`pretty`] crate to provide a flexible and configurable way to format complex
4+
//! data structures for display. The main entry point is the [`PrettyDisplayExt`] trait,
5+
//! which provides a [`PrettyDisplayExt::display`] method that returns a [`Display`] object to
6+
//! turn [`Pretty`] values into [`std::fmt::Display`] that can be used with standard formatting macros.
7+
//!
8+
//! This is primarily used for debugging and logging purposes, to make the output of the tool
9+
//! more readable.
10+
111
use rustc_index::{IndexSlice, IndexVec};
212

313
use pretty::{termcolor, BuildDoc, DocAllocator, DocPtr, Pretty};
414

15+
/// A wrapper around a [`crate::rty::FunctionType`] that provides a [`Pretty`] implementation.
516
pub struct FunctionType<'a, FV> {
617
pub params:
718
&'a rustc_index::IndexVec<crate::rty::FunctionParamIdx, crate::rty::RefinedType<FV>>,
@@ -36,6 +47,7 @@ impl<'a, FV> FunctionType<'a, FV> {
3647
}
3748
}
3849

50+
/// A wrapper around a slice that provides a [`Pretty`] implementation.
3951
#[derive(Debug, Clone)]
4052
pub struct PrettySlice<'a, T> {
4153
slice: &'a [T],
@@ -95,6 +107,7 @@ impl<I: rustc_index::Idx, T> PrettySliceExt for IndexVec<I, T> {
95107
}
96108
}
97109

110+
/// A wrapper around a type that provides a [`std::fmt::Display`] implementation via [`Pretty`].
98111
#[derive(Debug, Clone)]
99112
pub struct Display<'a, T> {
100113
value: &'a T,

0 commit comments

Comments
 (0)