From ebb81c433a30169078df226f5279a9f977858b86 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 2 Jun 2021 13:40:06 +1000 Subject: [PATCH 1/2] Add example to Slider.range() --- imgui/src/widget/slider.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/imgui/src/widget/slider.rs b/imgui/src/widget/slider.rs index 2b2604a..13a073c 100644 --- a/imgui/src/widget/slider.rs +++ b/imgui/src/widget/slider.rs @@ -48,6 +48,22 @@ impl<'a, T: DataTypeKind> Slider<'a, T> { } } /// Sets the range (inclusive) + /// + /// The argument uses the standard Rust [`std::ops::Range`] syntax. + /// + /// For example, to set both the min and max values: + /// + /// ```rust + /// imgui::Slider::new(im_str!("Example")) + /// .range(1 ..= 10) + /// ``` + /// + /// To set only the max value, using the default minimum value: + /// + /// ```rust + /// imgui::Slider::new(im_str!("Example")) + /// .range(..= 10) + /// ``` #[inline] pub fn range>(mut self, range: R) -> Self { self.min = range.start_bound().copied().unwrap_or(T::SLIDER_MIN); From 505f2be023bdf95399c00c96a30986b72f0a4f90 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 2 Jun 2021 14:07:30 +1000 Subject: [PATCH 2/2] Fix up doc tests --- imgui/src/widget/slider.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imgui/src/widget/slider.rs b/imgui/src/widget/slider.rs index 13a073c..314eb76 100644 --- a/imgui/src/widget/slider.rs +++ b/imgui/src/widget/slider.rs @@ -54,15 +54,21 @@ impl<'a, T: DataTypeKind> Slider<'a, T> { /// For example, to set both the min and max values: /// /// ```rust + /// # use imgui::im_str; /// imgui::Slider::new(im_str!("Example")) /// .range(1 ..= 10) + /// // Remember to call .build(&ui) + /// ; /// ``` /// /// To set only the max value, using the default minimum value: /// /// ```rust + /// # use imgui::im_str; /// imgui::Slider::new(im_str!("Example")) /// .range(..= 10) + /// // Remember to call .build(&ui) + /// ; /// ``` #[inline] pub fn range>(mut self, range: R) -> Self {