mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
janitor: Sprinkle #[must_use] over the codebase
This commit is contained in:
parent
df504897d6
commit
ac8f7b4957
9 changed files with 11 additions and 0 deletions
|
@ -530,6 +530,7 @@ pub trait ComponentHandle {
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
/// Returns a clone of this handle that's a strong reference.
|
/// Returns a clone of this handle that's a strong reference.
|
||||||
|
#[must_use]
|
||||||
fn clone_strong(&self) -> Self;
|
fn clone_strong(&self) -> Self;
|
||||||
|
|
||||||
/// Internal function used when upgrading a weak reference to a strong one.
|
/// Internal function used when upgrading a weak reference to a strong one.
|
||||||
|
|
|
@ -73,6 +73,7 @@ impl CompilerConfiguration {
|
||||||
|
|
||||||
/// Create a new configuration that includes sets the include paths used for looking up
|
/// Create a new configuration that includes sets the include paths used for looking up
|
||||||
/// `.60` imports to the specified vector of paths.
|
/// `.60` imports to the specified vector of paths.
|
||||||
|
#[must_use]
|
||||||
pub fn with_include_paths(self, include_paths: Vec<std::path::PathBuf>) -> Self {
|
pub fn with_include_paths(self, include_paths: Vec<std::path::PathBuf>) -> Self {
|
||||||
let mut config = self.config;
|
let mut config = self.config;
|
||||||
config.include_paths = include_paths;
|
config.include_paths = include_paths;
|
||||||
|
@ -80,6 +81,7 @@ impl CompilerConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new configuration that selects the style to be used for widgets.
|
/// Create a new configuration that selects the style to be used for widgets.
|
||||||
|
#[must_use]
|
||||||
pub fn with_style(self, style: String) -> Self {
|
pub fn with_style(self, style: String) -> Self {
|
||||||
let mut config = self.config;
|
let mut config = self.config;
|
||||||
config.style = Some(style);
|
config.style = Some(style);
|
||||||
|
|
|
@ -469,6 +469,7 @@ impl BuildDiagnostics {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "display-diagnostics")]
|
#[cfg(feature = "display-diagnostics")]
|
||||||
|
#[must_use]
|
||||||
pub fn check_and_exit_on_error(self) -> Self {
|
pub fn check_and_exit_on_error(self) -> Self {
|
||||||
if self.has_error() {
|
if self.has_error() {
|
||||||
self.print();
|
self.print();
|
||||||
|
|
|
@ -839,6 +839,7 @@ impl Expression {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a conversion node if needed, or throw an error if the type is not matching
|
/// Create a conversion node if needed, or throw an error if the type is not matching
|
||||||
|
#[must_use]
|
||||||
pub fn maybe_convert_to(
|
pub fn maybe_convert_to(
|
||||||
self,
|
self,
|
||||||
target_type: Type,
|
target_type: Type,
|
||||||
|
|
|
@ -142,6 +142,7 @@ pub struct FontRequest {
|
||||||
impl FontRequest {
|
impl FontRequest {
|
||||||
/// Consumes the FontRequest, replaces any missing fields from the specified other request and
|
/// Consumes the FontRequest, replaces any missing fields from the specified other request and
|
||||||
/// returns the new request.
|
/// returns the new request.
|
||||||
|
#[must_use]
|
||||||
pub fn merge(self, other: &FontRequest) -> Self {
|
pub fn merge(self, other: &FontRequest) -> Self {
|
||||||
Self {
|
Self {
|
||||||
family: self.family.or_else(|| other.family.clone()),
|
family: self.family.or_else(|| other.family.clone()),
|
||||||
|
|
|
@ -170,6 +170,7 @@ impl Color {
|
||||||
/// The result is converted back to RGB and the alpha channel is unchanged.
|
/// The result is converted back to RGB and the alpha channel is unchanged.
|
||||||
/// So for example `brighter(0.2)` will increase the brightness by 20%, and
|
/// So for example `brighter(0.2)` will increase the brightness by 20%, and
|
||||||
/// calling `brighter(-0.5)` will return a color that's 50% darker.
|
/// calling `brighter(-0.5)` will return a color that's 50% darker.
|
||||||
|
#[must_use]
|
||||||
pub fn brighter(&self, factor: f32) -> Self {
|
pub fn brighter(&self, factor: f32) -> Self {
|
||||||
let rgba: RgbaColor<f32> = (*self).into();
|
let rgba: RgbaColor<f32> = (*self).into();
|
||||||
let mut hsva: HsvaColor = rgba.into();
|
let mut hsva: HsvaColor = rgba.into();
|
||||||
|
@ -183,6 +184,7 @@ impl Color {
|
||||||
/// color space and dividing the brightness (value) by (1 + factor). The
|
/// color space and dividing the brightness (value) by (1 + factor). The
|
||||||
/// result is converted back to RGB and the alpha channel is unchanged.
|
/// result is converted back to RGB and the alpha channel is unchanged.
|
||||||
/// So for example `darker(0.3)` will decrease the brightness by 30%.
|
/// So for example `darker(0.3)` will decrease the brightness by 30%.
|
||||||
|
#[must_use]
|
||||||
pub fn darker(&self, factor: f32) -> Self {
|
pub fn darker(&self, factor: f32) -> Self {
|
||||||
let rgba: RgbaColor<f32> = (*self).into();
|
let rgba: RgbaColor<f32> = (*self).into();
|
||||||
let mut hsva: HsvaColor = rgba.into();
|
let mut hsva: HsvaColor = rgba.into();
|
||||||
|
|
|
@ -53,6 +53,7 @@ impl Default for LayoutInfo {
|
||||||
|
|
||||||
impl LayoutInfo {
|
impl LayoutInfo {
|
||||||
// Note: This "logic" is duplicated in the cpp generator's generated code for merging layout infos.
|
// Note: This "logic" is duplicated in the cpp generator's generated code for merging layout infos.
|
||||||
|
#[must_use]
|
||||||
pub fn merge(&self, other: &LayoutInfo) -> Self {
|
pub fn merge(&self, other: &LayoutInfo) -> Self {
|
||||||
Self {
|
Self {
|
||||||
min: self.min.max(other.min),
|
min: self.min.max(other.min),
|
||||||
|
|
|
@ -1228,6 +1228,7 @@ pub trait InterpolatedPropertyValue: PartialEq + Default + 'static {
|
||||||
/// Returns the interpolated value between self and target_value according to the
|
/// Returns the interpolated value between self and target_value according to the
|
||||||
/// progress parameter t that's usually between 0 and 1. With certain animation
|
/// progress parameter t that's usually between 0 and 1. With certain animation
|
||||||
/// easing curves it may over- or undershoot though.
|
/// easing curves it may over- or undershoot though.
|
||||||
|
#[must_use]
|
||||||
fn interpolate(&self, target_value: &Self, t: f32) -> Self;
|
fn interpolate(&self, target_value: &Self, t: f32) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -992,6 +992,7 @@ impl ComponentInstance {
|
||||||
/// Clone is not implemented because of the danger of circular reference:
|
/// Clone is not implemented because of the danger of circular reference:
|
||||||
/// If you want to use this instance in a callback, you should capture a weak
|
/// If you want to use this instance in a callback, you should capture a weak
|
||||||
/// reference given by [`Self::as_weak`].
|
/// reference given by [`Self::as_weak`].
|
||||||
|
#[must_use]
|
||||||
pub fn clone_strong(&self) -> Self {
|
pub fn clone_strong(&self) -> Self {
|
||||||
Self { inner: self.inner.clone() }
|
Self { inner: self.inner.clone() }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue