Add more Debug implementations

I generally like to implement Debug on these kind of types.
This commit is contained in:
John Nunley 2023-07-07 21:44:21 -07:00
parent 7d50d17369
commit 440d24ffa0
No known key found for this signature in database
GPG key ID: 42B2FA4582BB1EC9
15 changed files with 38 additions and 1 deletions

View file

@ -206,7 +206,7 @@ impl AttrsOwned {
/// List of text attributes to apply to a line /// List of text attributes to apply to a line
//TODO: have this clean up the spans when changes are made //TODO: have this clean up the spans when changes are made
#[derive(Eq, PartialEq)] #[derive(Debug, Eq, PartialEq)]
pub struct AttrsList { pub struct AttrsList {
defaults: AttrsOwned, defaults: AttrsOwned,
spans: RangeMap<usize, AttrsOwned>, spans: RangeMap<usize, AttrsOwned>,

View file

@ -4,6 +4,7 @@ use unicode_bidi::{bidi_class, BidiClass, BidiInfo, ParagraphInfo};
/// An iterator over the paragraphs in the input text. /// An iterator over the paragraphs in the input text.
/// It is equivalent to [`core::str::Lines`] but follows `unicode-bidi` behaviour. /// It is equivalent to [`core::str::Lines`] but follows `unicode-bidi` behaviour.
#[derive(Debug)]
pub struct BidiParagraphs<'text> { pub struct BidiParagraphs<'text> {
text: &'text str, text: &'text str,
info: alloc::vec::IntoIter<ParagraphInfo>, info: alloc::vec::IntoIter<ParagraphInfo>,

View file

@ -93,6 +93,7 @@ impl Default for Affinity {
} }
/// The position of a cursor within a [`Buffer`]. /// The position of a cursor within a [`Buffer`].
#[derive(Debug)]
pub struct LayoutCursor { pub struct LayoutCursor {
pub line: usize, pub line: usize,
pub layout: usize, pub layout: usize,
@ -110,6 +111,7 @@ impl LayoutCursor {
} }
/// A line of visible text for rendering /// A line of visible text for rendering
#[derive(Debug)]
pub struct LayoutRun<'a> { pub struct LayoutRun<'a> {
/// The index of the original text line /// The index of the original text line
pub line_i: usize, pub line_i: usize,
@ -184,6 +186,7 @@ impl<'a> LayoutRun<'a> {
} }
/// An iterator of visible text lines, see [`LayoutRun`] /// An iterator of visible text lines, see [`LayoutRun`]
#[derive(Debug)]
pub struct LayoutRunIter<'b> { pub struct LayoutRunIter<'b> {
buffer: &'b Buffer, buffer: &'b Buffer,
line_i: usize, line_i: usize,
@ -316,6 +319,7 @@ impl fmt::Display for Metrics {
} }
/// A buffer of text that is shaped and laid out /// A buffer of text that is shaped and laid out
#[derive(Debug)]
pub struct Buffer { pub struct Buffer {
/// [BufferLine]s (or paragraphs) of text in the buffer /// [BufferLine]s (or paragraphs) of text in the buffer
pub lines: Vec<BufferLine>, pub lines: Vec<BufferLine>,

View file

@ -4,6 +4,7 @@ use alloc::{string::String, vec::Vec};
use crate::{Align, AttrsList, FontSystem, LayoutLine, ShapeLine, Shaping, Wrap}; use crate::{Align, AttrsList, FontSystem, LayoutLine, ShapeLine, Shaping, Wrap};
/// A line (or paragraph) of text that is shaped and laid out /// A line (or paragraph) of text that is shaped and laid out
#[derive(Debug)]
pub struct BufferLine { pub struct BufferLine {
//TODO: make this not pub(crate) //TODO: make this not pub(crate)
text: String, text: String,

View file

@ -16,6 +16,7 @@ use crate::{
}; };
/// A wrapper of [`Buffer`] for easy editing /// A wrapper of [`Buffer`] for easy editing
#[derive(Debug)]
pub struct Editor { pub struct Editor {
buffer: Buffer, buffer: Buffer,
cursor: Cursor, cursor: Cursor,

View file

@ -12,6 +12,7 @@ use crate::{
Shaping, Style, Weight, Wrap, Shaping, Style, Weight, Wrap,
}; };
#[derive(Debug)]
pub struct SyntaxSystem { pub struct SyntaxSystem {
pub syntax_set: SyntaxSet, pub syntax_set: SyntaxSet,
pub theme_set: ThemeSet, pub theme_set: ThemeSet,
@ -29,6 +30,7 @@ impl SyntaxSystem {
} }
/// A wrapper of [`Editor`] with syntax highlighting provided by [`SyntaxSystem`] /// A wrapper of [`Editor`] with syntax highlighting provided by [`SyntaxSystem`]
#[derive(Debug)]
pub struct SyntaxEditor<'a> { pub struct SyntaxEditor<'a> {
editor: Editor, editor: Editor,
syntax_system: &'a SyntaxSystem, syntax_system: &'a SyntaxSystem,

View file

@ -16,6 +16,7 @@ enum Mode {
SearchBackwards, SearchBackwards,
} }
#[derive(Debug)]
pub struct ViEditor<'a> { pub struct ViEditor<'a> {
editor: SyntaxEditor<'a>, editor: SyntaxEditor<'a>,
mode: Mode, mode: Mode,

View file

@ -14,6 +14,7 @@ pub use font_inner::Font;
mod font_inner { mod font_inner {
use super::*; use super::*;
use aliasable::boxed::AliasableBox; use aliasable::boxed::AliasableBox;
use core::fmt;
/// A font /// A font
// //
@ -31,6 +32,14 @@ mod font_inner {
id: fontdb::ID, id: fontdb::ID,
} }
impl fmt::Debug for Font {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Font")
.field("id", &self.id)
.finish_non_exhaustive()
}
}
pub(super) struct FontTryBuilder< pub(super) struct FontTryBuilder<
RustybuzzBuilder: for<'this> FnOnce( RustybuzzBuilder: for<'this> FnOnce(
&'this Arc<dyn AsRef<[u8]> + Send + Sync>, &'this Arc<dyn AsRef<[u8]> + Send + Sync>,

View file

@ -15,6 +15,7 @@ pub use fontdb;
pub use rustybuzz; pub use rustybuzz;
/// A value borrowed together with an [`FontSystem`] /// A value borrowed together with an [`FontSystem`]
#[derive(Debug)]
pub struct BorrowedWithFontSystem<'a, T> { pub struct BorrowedWithFontSystem<'a, T> {
pub(crate) inner: &'a mut T, pub(crate) inner: &'a mut T,
pub(crate) font_system: &'a mut FontSystem, pub(crate) font_system: &'a mut FontSystem,

View file

@ -9,6 +9,7 @@ use alloc::{
use crate::{Attrs, Font}; use crate::{Attrs, Font};
/// Access system fonts /// Access system fonts
#[derive(Debug)]
pub struct FontSystem { pub struct FontSystem {
locale: String, locale: String,
db: fontdb::Database, db: fontdb::Database,

View file

@ -5,6 +5,7 @@ use std::{collections::HashMap, sync::Arc};
use crate::{Attrs, AttrsOwned, Font}; use crate::{Attrs, AttrsOwned, Font};
/// Access system fonts /// Access system fonts
#[derive(Debug)]
pub struct FontSystem { pub struct FontSystem {
locale: String, locale: String,
db: fontdb::Database, db: fontdb::Database,

View file

@ -52,6 +52,7 @@ pub struct LayoutGlyph {
pub metadata: usize, pub metadata: usize,
} }
#[derive(Debug)]
pub struct PhysicalGlyph { pub struct PhysicalGlyph {
/// Cache key, see [CacheKey] /// Cache key, see [CacheKey]
pub cache_key: CacheKey, pub cache_key: CacheKey,
@ -81,6 +82,7 @@ impl LayoutGlyph {
} }
/// A line of laid out glyphs /// A line of laid out glyphs
#[derive(Debug)]
pub struct LayoutLine { pub struct LayoutLine {
/// Width of the line /// Width of the line
pub w: f32, pub w: f32,

View file

@ -71,6 +71,8 @@
#![deny(clippy::cast_ptr_alignment)] #![deny(clippy::cast_ptr_alignment)]
// Avoid panicking in without information about the panic. Use expect // Avoid panicking in without information about the panic. Use expect
#![deny(clippy::unwrap_used)] #![deny(clippy::unwrap_used)]
// Ensure all types have a debug impl
#![deny(missing_debug_implementations)]
// This is usually a serious issue - a missing import of a define where it is interpreted // This is usually a serious issue - a missing import of a define where it is interpreted
// as a catch-all variable in a match, for example // as a catch-all variable in a match, for example
#![deny(unreachable_patterns)] #![deny(unreachable_patterns)]

View file

@ -308,6 +308,7 @@ fn shape_skip(
} }
/// A shaped glyph /// A shaped glyph
#[derive(Debug)]
pub struct ShapeGlyph { pub struct ShapeGlyph {
pub start: usize, pub start: usize,
pub end: usize, pub end: usize,
@ -351,6 +352,7 @@ impl ShapeGlyph {
} }
/// A shaped word (for word wrapping) /// A shaped word (for word wrapping)
#[derive(Debug)]
pub struct ShapeWord { pub struct ShapeWord {
pub blank: bool, pub blank: bool,
pub glyphs: Vec<ShapeGlyph>, pub glyphs: Vec<ShapeGlyph>,
@ -428,6 +430,7 @@ impl ShapeWord {
} }
/// A shaped span (for bidirectional processing) /// A shaped span (for bidirectional processing)
#[derive(Debug)]
pub struct ShapeSpan { pub struct ShapeSpan {
pub level: unicode_bidi::Level, pub level: unicode_bidi::Level,
pub words: Vec<ShapeWord>, pub words: Vec<ShapeWord>,
@ -510,6 +513,7 @@ impl ShapeSpan {
} }
/// A shaped line (or paragraph) /// A shaped line (or paragraph)
#[derive(Debug)]
pub struct ShapeLine { pub struct ShapeLine {
pub rtl: bool, pub rtl: bool,
pub spans: Vec<ShapeSpan>, pub spans: Vec<ShapeSpan>,

View file

@ -4,6 +4,7 @@
use alloc::collections::BTreeMap as Map; use alloc::collections::BTreeMap as Map;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::fmt;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::collections::HashMap as Map; use std::collections::HashMap as Map;
use swash::scale::{image::Content, ScaleContext}; use swash::scale::{image::Content, ScaleContext};
@ -96,6 +97,12 @@ pub struct SwashCache {
pub outline_command_cache: Map<CacheKey, Option<Vec<swash::zeno::Command>>>, pub outline_command_cache: Map<CacheKey, Option<Vec<swash::zeno::Command>>>,
} }
impl fmt::Debug for SwashCache {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("SwashCache { .. }")
}
}
impl SwashCache { impl SwashCache {
/// Create a new swash cache /// Create a new swash cache
pub fn new() -> Self { pub fn new() -> Self {