|
| 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 | +
|
1 | 11 | use rustc_index::{IndexSlice, IndexVec}; |
2 | 12 |
|
3 | 13 | use pretty::{termcolor, BuildDoc, DocAllocator, DocPtr, Pretty}; |
4 | 14 |
|
| 15 | +/// A wrapper around a [`crate::rty::FunctionType`] that provides a [`Pretty`] implementation. |
5 | 16 | pub struct FunctionType<'a, FV> { |
6 | 17 | pub params: |
7 | 18 | &'a rustc_index::IndexVec<crate::rty::FunctionParamIdx, crate::rty::RefinedType<FV>>, |
@@ -36,6 +47,7 @@ impl<'a, FV> FunctionType<'a, FV> { |
36 | 47 | } |
37 | 48 | } |
38 | 49 |
|
| 50 | +/// A wrapper around a slice that provides a [`Pretty`] implementation. |
39 | 51 | #[derive(Debug, Clone)] |
40 | 52 | pub struct PrettySlice<'a, T> { |
41 | 53 | slice: &'a [T], |
@@ -95,6 +107,7 @@ impl<I: rustc_index::Idx, T> PrettySliceExt for IndexVec<I, T> { |
95 | 107 | } |
96 | 108 | } |
97 | 109 |
|
| 110 | +/// A wrapper around a type that provides a [`std::fmt::Display`] implementation via [`Pretty`]. |
98 | 111 | #[derive(Debug, Clone)] |
99 | 112 | pub struct Display<'a, T> { |
100 | 113 | value: &'a T, |
|
0 commit comments