From 565599876172b3f56d86b119ae453b5bcd8949e1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 4 Feb 2025 07:53:56 +0100 Subject: Draft `Viewer` trait for `markdown` --- core/src/padding.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core') diff --git a/core/src/padding.rs b/core/src/padding.rs index e26cdd9b..9ec02e6d 100644 --- a/core/src/padding.rs +++ b/core/src/padding.rs @@ -202,3 +202,9 @@ impl From for Size { Self::new(padding.horizontal(), padding.vertical()) } } + +impl From for Padding { + fn from(pixels: Pixels) -> Self { + Self::from(pixels.0) + } +} -- cgit From 24cf355e96d8ae6432ca8972214c2c4f31d07b22 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 4 Feb 2025 19:07:24 +0100 Subject: Fix documentation of `markdown` and `rich_text` --- core/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core') diff --git a/core/src/lib.rs b/core/src/lib.rs index c31a8da7..d5c221ac 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -84,3 +84,12 @@ pub use vector::Vector; pub use widget::Widget; pub use smol_str::SmolStr; + +/// A function that can _never_ be called. +/// +/// This is useful to turn generic types into anything +/// you want by coercing them into a type with no possible +/// values. +pub fn never(never: std::convert::Infallible) -> T { + match never {} +} -- cgit From e8020f3eaf3baec2b41847f6250d8554136e8d89 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 4 Feb 2025 20:58:06 +0100 Subject: Add `Copy` action to code blocks in `markdown` example --- core/src/pixels.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core') diff --git a/core/src/pixels.rs b/core/src/pixels.rs index a1ea0f15..7d6267cf 100644 --- a/core/src/pixels.rs +++ b/core/src/pixels.rs @@ -79,3 +79,11 @@ impl std::ops::Div for Pixels { Pixels(self.0 / rhs) } } + +impl std::ops::Div for Pixels { + type Output = Pixels; + + fn div(self, rhs: u32) -> Self { + Pixels(self.0 / rhs as f32) + } +} -- cgit