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;
|
||||
|
||||
/// Returns a clone of this handle that's a strong reference.
|
||||
#[must_use]
|
||||
fn clone_strong(&self) -> Self;
|
||||
|
||||
/// 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
|
||||
/// `.60` imports to the specified vector of paths.
|
||||
#[must_use]
|
||||
pub fn with_include_paths(self, include_paths: Vec<std::path::PathBuf>) -> Self {
|
||||
let mut config = self.config;
|
||||
config.include_paths = include_paths;
|
||||
|
@ -80,6 +81,7 @@ impl CompilerConfiguration {
|
|||
}
|
||||
|
||||
/// Create a new configuration that selects the style to be used for widgets.
|
||||
#[must_use]
|
||||
pub fn with_style(self, style: String) -> Self {
|
||||
let mut config = self.config;
|
||||
config.style = Some(style);
|
||||
|
|
|
@ -469,6 +469,7 @@ impl BuildDiagnostics {
|
|||
}
|
||||
|
||||
#[cfg(feature = "display-diagnostics")]
|
||||
#[must_use]
|
||||
pub fn check_and_exit_on_error(self) -> Self {
|
||||
if self.has_error() {
|
||||
self.print();
|
||||
|
|
|
@ -839,6 +839,7 @@ impl Expression {
|
|||
}
|
||||
|
||||
/// Create a conversion node if needed, or throw an error if the type is not matching
|
||||
#[must_use]
|
||||
pub fn maybe_convert_to(
|
||||
self,
|
||||
target_type: Type,
|
||||
|
|
|
@ -142,6 +142,7 @@ pub struct FontRequest {
|
|||
impl FontRequest {
|
||||
/// Consumes the FontRequest, replaces any missing fields from the specified other request and
|
||||
/// returns the new request.
|
||||
#[must_use]
|
||||
pub fn merge(self, other: &FontRequest) -> Self {
|
||||
Self {
|
||||
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.
|
||||
/// 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.
|
||||
#[must_use]
|
||||
pub fn brighter(&self, factor: f32) -> Self {
|
||||
let rgba: RgbaColor<f32> = (*self).into();
|
||||
let mut hsva: HsvaColor = rgba.into();
|
||||
|
@ -183,6 +184,7 @@ impl Color {
|
|||
/// color space and dividing the brightness (value) by (1 + factor). The
|
||||
/// result is converted back to RGB and the alpha channel is unchanged.
|
||||
/// So for example `darker(0.3)` will decrease the brightness by 30%.
|
||||
#[must_use]
|
||||
pub fn darker(&self, factor: f32) -> Self {
|
||||
let rgba: RgbaColor<f32> = (*self).into();
|
||||
let mut hsva: HsvaColor = rgba.into();
|
||||
|
|
|
@ -53,6 +53,7 @@ impl Default for LayoutInfo {
|
|||
|
||||
impl LayoutInfo {
|
||||
// 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 {
|
||||
Self {
|
||||
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
|
||||
/// progress parameter t that's usually between 0 and 1. With certain animation
|
||||
/// easing curves it may over- or undershoot though.
|
||||
#[must_use]
|
||||
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:
|
||||
/// If you want to use this instance in a callback, you should capture a weak
|
||||
/// reference given by [`Self::as_weak`].
|
||||
#[must_use]
|
||||
pub fn clone_strong(&self) -> Self {
|
||||
Self { inner: self.inner.clone() }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue