Mark XY::stack_{horizontal, vertical} as must_use (#511)

The method names stack_horizontal and stack_vertical don’t make it clear
whether the methods modify self or return the modified version.
Therefore, it is easy to use them wrong if you don’t look at the
documentation.  This patch adds the must_use attribute to both methods
to make it easier to spot such mistakes.
This commit is contained in:
Robin Krahl 2020-10-06 23:21:56 +02:00 committed by GitHub
parent 3f60d383aa
commit 0e2a111f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -258,6 +258,7 @@ impl<T: Ord> XY<T> {
impl<T: Ord + Add<Output = T> + Clone> XY<T> { impl<T: Ord + Add<Output = T> + Clone> XY<T> {
/// Returns (max(self.x,other.x), self.y+other.y) /// Returns (max(self.x,other.x), self.y+other.y)
#[must_use]
pub fn stack_vertical(&self, other: &Self) -> Self { pub fn stack_vertical(&self, other: &Self) -> Self {
Self::new( Self::new(
max(self.x.clone(), other.x.clone()), max(self.x.clone(), other.x.clone()),
@ -266,6 +267,7 @@ impl<T: Ord + Add<Output = T> + Clone> XY<T> {
} }
/// Returns (self.x+other.x, max(self.y,other.y)) /// Returns (self.x+other.x, max(self.y,other.y))
#[must_use]
pub fn stack_horizontal(&self, other: &Self) -> Self { pub fn stack_horizontal(&self, other: &Self) -> Self {
Self::new( Self::new(
self.x.clone() + other.x.clone(), self.x.clone() + other.x.clone(),