diff --git a/clippy.toml b/clippy.toml index 302f26e0..13d3926a 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,4 +1,4 @@ -avoid-breaking-exported-api = true +avoid-breaking-exported-api = false cognitive-complexity-threshold = 50 too-many-arguments-threshold = 10 type-complexity-threshold = 500 \ No newline at end of file diff --git a/lib/oxsdatatypes/src/boolean.rs b/lib/oxsdatatypes/src/boolean.rs index fd213a90..7ce5d977 100644 --- a/lib/oxsdatatypes/src/boolean.rs +++ b/lib/oxsdatatypes/src/boolean.rs @@ -14,7 +14,7 @@ pub struct Boolean { impl Boolean { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self == other } } diff --git a/lib/oxsdatatypes/src/date_time.rs b/lib/oxsdatatypes/src/date_time.rs index b5763220..8d005a46 100644 --- a/lib/oxsdatatypes/src/date_time.rs +++ b/lib/oxsdatatypes/src/date_time.rs @@ -60,53 +60,53 @@ impl DateTime { /// [fn:year-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-year-from-dateTime) #[inline] - pub fn year(&self) -> i64 { + pub fn year(self) -> i64 { self.timestamp.year() } /// [fn:month-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-month-from-dateTime) #[inline] - pub fn month(&self) -> u8 { + pub fn month(self) -> u8 { self.timestamp.month() } /// [fn:day-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-day-from-dateTime) #[inline] - pub fn day(&self) -> u8 { + pub fn day(self) -> u8 { self.timestamp.day() } /// [fn:hour-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-dateTime) #[inline] - pub fn hour(&self) -> u8 { + pub fn hour(self) -> u8 { self.timestamp.hour() } /// [fn:minute-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-dateTime) #[inline] - pub fn minute(&self) -> u8 { + pub fn minute(self) -> u8 { self.timestamp.minute() } /// [fn:second-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-dateTime) #[inline] - pub fn second(&self) -> Decimal { + pub fn second(self) -> Decimal { self.timestamp.second() } /// [fn:timezone-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-dateTime) #[inline] - pub fn timezone(&self) -> Option { + pub fn timezone(self) -> Option { Some(self.timezone_offset()?.into()) } #[inline] - pub fn timezone_offset(&self) -> Option { + pub fn timezone_offset(self) -> Option { self.timestamp.timezone_offset() } #[inline] - fn properties(&self) -> DateTimeSevenPropertyModel { + fn properties(self) -> DateTimeSevenPropertyModel { DateTimeSevenPropertyModel { year: Some(self.year()), month: Some(self.month()), @@ -125,14 +125,14 @@ impl DateTime { /// [op:subtract-dateTimes](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dateTimes) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { self.timestamp.checked_sub(rhs.into().timestamp) } /// [op:add-yearMonthDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-dateTime) #[inline] pub fn checked_add_year_month_duration( - &self, + self, rhs: impl Into, ) -> Option { self.checked_add_duration(Duration::from(rhs.into())) @@ -140,7 +140,7 @@ impl DateTime { /// [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-dateTime) #[inline] - pub fn checked_add_day_time_duration(&self, rhs: impl Into) -> Option { + pub fn checked_add_day_time_duration(self, rhs: impl Into) -> Option { let rhs = rhs.into(); Some(Self { timestamp: self.timestamp.checked_add_seconds(rhs.all_seconds())?, @@ -149,7 +149,7 @@ impl DateTime { /// [op:add-yearMonthDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-dateTime) and [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-dateTime) #[inline] - pub fn checked_add_duration(&self, rhs: impl Into) -> Option { + pub fn checked_add_duration(self, rhs: impl Into) -> Option { let rhs = rhs.into(); if let Ok(rhs) = DayTimeDuration::try_from(rhs) { self.checked_add_day_time_duration(rhs) @@ -164,7 +164,7 @@ impl DateTime { /// [op:subtract-yearMonthDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-dateTime) #[inline] pub fn checked_sub_year_month_duration( - &self, + self, rhs: impl Into, ) -> Option { self.checked_sub_duration(Duration::from(rhs.into())) @@ -172,7 +172,7 @@ impl DateTime { /// [op:subtract-dayTimeDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-dateTime) #[inline] - pub fn checked_sub_day_time_duration(&self, rhs: impl Into) -> Option { + pub fn checked_sub_day_time_duration(self, rhs: impl Into) -> Option { let rhs = rhs.into(); Some(Self { timestamp: self.timestamp.checked_sub_seconds(rhs.all_seconds())?, @@ -181,7 +181,7 @@ impl DateTime { /// [op:subtract-yearMonthDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-dateTime) and [op:subtract-dayTimeDuration-from-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-dateTime) #[inline] - pub fn checked_sub_duration(&self, rhs: impl Into) -> Option { + pub fn checked_sub_duration(self, rhs: impl Into) -> Option { let rhs = rhs.into(); if let Ok(rhs) = DayTimeDuration::try_from(rhs) { self.checked_sub_day_time_duration(rhs) @@ -198,7 +198,7 @@ impl DateTime { /// [fn:adjust-dateTime-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-dateTime-to-timezone) #[inline] - pub fn adjust(&self, timezone_offset: Option) -> Option { + pub fn adjust(self, timezone_offset: Option) -> Option { Some(Self { timestamp: self.timestamp.adjust(timezone_offset)?, }) @@ -206,8 +206,8 @@ impl DateTime { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -314,30 +314,30 @@ impl Time { /// [fn:hour-from-time](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-time) #[inline] - pub fn hour(&self) -> u8 { + pub fn hour(self) -> u8 { self.timestamp.hour() } /// [fn:minute-from-time](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-time) #[inline] - pub fn minute(&self) -> u8 { + pub fn minute(self) -> u8 { self.timestamp.minute() } /// [fn:second-from-time](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-time) #[inline] - pub fn second(&self) -> Decimal { + pub fn second(self) -> Decimal { self.timestamp.second() } /// [fn:timezone-from-time](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-time) #[inline] - pub fn timezone(&self) -> Option { + pub fn timezone(self) -> Option { Some(self.timezone_offset()?.into()) } #[inline] - pub fn timezone_offset(&self) -> Option { + pub fn timezone_offset(self) -> Option { self.timestamp.timezone_offset() } @@ -348,19 +348,19 @@ impl Time { /// [op:subtract-times](https://www.w3.org/TR/xpath-functions-31/#func-subtract-times) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { self.timestamp.checked_sub(rhs.into().timestamp) } /// [op:add-dayTimeDuration-to-time](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-time) #[inline] - pub fn checked_add_day_time_duration(&self, rhs: impl Into) -> Option { + pub fn checked_add_day_time_duration(self, rhs: impl Into) -> Option { self.checked_add_duration(Duration::from(rhs.into())) } /// [op:add-dayTimeDuration-to-time](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-time) #[inline] - pub fn checked_add_duration(&self, rhs: impl Into) -> Option { + pub fn checked_add_duration(self, rhs: impl Into) -> Option { DateTime::new( 1972, 12, @@ -378,13 +378,13 @@ impl Time { /// [op:subtract-dayTimeDuration-from-time](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-time) #[inline] - pub fn checked_sub_day_time_duration(&self, rhs: impl Into) -> Option { + pub fn checked_sub_day_time_duration(self, rhs: impl Into) -> Option { self.checked_sub_duration(Duration::from(rhs.into())) } /// [op:subtract-dayTimeDuration-from-time](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-time) #[inline] - pub fn checked_sub_duration(&self, rhs: impl Into) -> Option { + pub fn checked_sub_duration(self, rhs: impl Into) -> Option { DateTime::new( 1972, 12, @@ -402,7 +402,7 @@ impl Time { // [fn:adjust-time-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-time-to-timezone) #[inline] - pub fn adjust(&self, timezone_offset: Option) -> Option { + pub fn adjust(self, timezone_offset: Option) -> Option { DateTime::new( 1972, 12, @@ -420,8 +420,8 @@ impl Time { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -515,30 +515,30 @@ impl Date { /// [fn:year-from-date](https://www.w3.org/TR/xpath-functions-31/#func-year-from-date) #[inline] - pub fn year(&self) -> i64 { + pub fn year(self) -> i64 { self.timestamp.year() } /// [fn:month-from-date](https://www.w3.org/TR/xpath-functions-31/#func-month-from-date) #[inline] - pub fn month(&self) -> u8 { + pub fn month(self) -> u8 { self.timestamp.month() } /// [fn:day-from-date](https://www.w3.org/TR/xpath-functions-31/#func-day-from-date) #[inline] - pub fn day(&self) -> u8 { + pub fn day(self) -> u8 { self.timestamp.day() } /// [fn:timezone-from-date](https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-date) #[inline] - pub fn timezone(&self) -> Option { + pub fn timezone(self) -> Option { Some(self.timezone_offset()?.into()) } #[inline] - pub fn timezone_offset(&self) -> Option { + pub fn timezone_offset(self) -> Option { self.timestamp.timezone_offset() } @@ -549,14 +549,14 @@ impl Date { /// [op:subtract-dates](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dates) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { self.timestamp.checked_sub(rhs.into().timestamp) } /// [op:add-yearMonthDuration-to-date](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-date) #[inline] pub fn checked_add_year_month_duration( - &self, + self, rhs: impl Into, ) -> Option { self.checked_add_duration(Duration::from(rhs.into())) @@ -564,14 +564,14 @@ impl Date { /// [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-date) #[inline] - pub fn checked_add_day_time_duration(&self, rhs: impl Into) -> Option { + pub fn checked_add_day_time_duration(self, rhs: impl Into) -> Option { self.checked_add_duration(Duration::from(rhs.into())) } /// [op:add-yearMonthDuration-to-date](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDuration-to-date) and [op:add-dayTimeDuration-to-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDuration-to-date) #[inline] - pub fn checked_add_duration(&self, rhs: impl Into) -> Option { - DateTime::try_from(*self) + pub fn checked_add_duration(self, rhs: impl Into) -> Option { + DateTime::try_from(self) .ok()? .checked_add_duration(rhs)? .try_into() @@ -581,7 +581,7 @@ impl Date { /// [op:subtract-yearMonthDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-date) #[inline] pub fn checked_sub_year_month_duration( - &self, + self, rhs: impl Into, ) -> Option { self.checked_sub_duration(Duration::from(rhs.into())) @@ -589,14 +589,14 @@ impl Date { /// [op:subtract-dayTimeDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-date) #[inline] - pub fn checked_sub_day_time_duration(&self, rhs: impl Into) -> Option { + pub fn checked_sub_day_time_duration(self, rhs: impl Into) -> Option { self.checked_sub_duration(Duration::from(rhs.into())) } /// [op:subtract-yearMonthDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDuration-from-date) and [op:subtract-dayTimeDuration-from-date](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDuration-from-date) #[inline] - pub fn checked_sub_duration(&self, rhs: impl Into) -> Option { - DateTime::try_from(*self) + pub fn checked_sub_duration(self, rhs: impl Into) -> Option { + DateTime::try_from(self) .ok()? .checked_sub_duration(rhs)? .try_into() @@ -605,7 +605,7 @@ impl Date { // [fn:adjust-date-to-timezone](https://www.w3.org/TR/xpath-functions-31/#func-adjust-date-to-timezone) #[inline] - pub fn adjust(&self, timezone_offset: Option) -> Option { + pub fn adjust(self, timezone_offset: Option) -> Option { DateTime::new( self.year(), self.month(), @@ -623,8 +623,8 @@ impl Date { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -703,27 +703,27 @@ impl GYearMonth { } #[inline] - pub fn year(&self) -> i64 { + pub fn year(self) -> i64 { self.timestamp.year() } #[inline] - pub fn month(&self) -> u8 { + pub fn month(self) -> u8 { self.timestamp.month() } #[inline] - pub fn timezone(&self) -> Option { + pub fn timezone(self) -> Option { Some(self.timezone_offset()?.into()) } #[inline] - pub fn timezone_offset(&self) -> Option { + pub fn timezone_offset(self) -> Option { self.timestamp.timezone_offset() } #[inline] - pub fn adjust(&self, timezone_offset: Option) -> Option { + pub fn adjust(self, timezone_offset: Option) -> Option { Some(Self { timestamp: self.timestamp.adjust(timezone_offset)?, }) @@ -736,8 +736,8 @@ impl GYearMonth { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -824,22 +824,22 @@ impl GYear { } #[inline] - pub fn year(&self) -> i64 { + pub fn year(self) -> i64 { self.timestamp.year() } #[inline] - pub fn timezone(&self) -> Option { + pub fn timezone(self) -> Option { Some(self.timezone_offset()?.into()) } #[inline] - pub fn timezone_offset(&self) -> Option { + pub fn timezone_offset(self) -> Option { self.timestamp.timezone_offset() } #[inline] - pub fn adjust(&self, timezone_offset: Option) -> Option { + pub fn adjust(self, timezone_offset: Option) -> Option { Some(Self { timestamp: self.timestamp.adjust(timezone_offset)?, }) @@ -852,8 +852,8 @@ impl GYear { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -979,8 +979,8 @@ impl GMonthDay { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -1091,8 +1091,8 @@ impl GMonth { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -1217,8 +1217,8 @@ impl GDay { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { - self.timestamp.is_identical_with(&other.timestamp) + pub fn is_identical_with(self, other: Self) -> bool { + self.timestamp.is_identical_with(other.timestamp) } } @@ -1650,7 +1650,7 @@ impl Timestamp { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self.value == other.value && self.timezone_offset == other.timezone_offset } } diff --git a/lib/oxsdatatypes/src/decimal.rs b/lib/oxsdatatypes/src/decimal.rs index 19d93fed..0fd4d3db 100644 --- a/lib/oxsdatatypes/src/decimal.rs +++ b/lib/oxsdatatypes/src/decimal.rs @@ -47,7 +47,7 @@ impl Decimal { /// [op:numeric-add](https://www.w3.org/TR/xpath-functions-31/#func-numeric-add) #[inline] - pub fn checked_add(&self, rhs: impl Into) -> Option { + pub fn checked_add(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_add(rhs.into().value)?, }) @@ -55,7 +55,7 @@ impl Decimal { /// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions-31/#func-numeric-subtract) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_sub(rhs.into().value)?, }) @@ -63,7 +63,7 @@ impl Decimal { /// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions-31/#func-numeric-multiply) #[inline] - pub fn checked_mul(&self, rhs: impl Into) -> Option { + pub fn checked_mul(self, rhs: impl Into) -> Option { // Idea: we shift right as much as possible to keep as much precision as possible // Do the multiplication and do the required left shift let mut left = self.value; @@ -95,7 +95,7 @@ impl Decimal { /// [op:numeric-divide](https://www.w3.org/TR/xpath-functions-31/#func-numeric-divide) #[inline] - pub fn checked_div(&self, rhs: impl Into) -> Option { + pub fn checked_div(self, rhs: impl Into) -> Option { // Idea: we shift the dividend left as much as possible to keep as much precision as possible // And we shift right the divisor as much as possible // Do the multiplication and do the required shift @@ -128,14 +128,14 @@ impl Decimal { /// [op:numeric-mod](https://www.w3.org/TR/xpath-functions-31/#func-numeric-mod) #[inline] - pub fn checked_rem(&self, rhs: impl Into) -> Option { + pub fn checked_rem(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_rem(rhs.into().value)?, }) } #[inline] - pub fn checked_rem_euclid(&self, rhs: impl Into) -> Option { + pub fn checked_rem_euclid(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_rem_euclid(rhs.into().value)?, }) @@ -143,7 +143,7 @@ impl Decimal { /// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions-31/#func-numeric-unary-minus) #[inline] - pub fn checked_neg(&self) -> Option { + pub fn checked_neg(self) -> Option { Some(Self { value: self.value.checked_neg()?, }) @@ -151,7 +151,7 @@ impl Decimal { /// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs) #[inline] - pub const fn abs(&self) -> Self { + pub const fn abs(self) -> Self { Self { value: self.value.abs(), } @@ -159,7 +159,7 @@ impl Decimal { /// [fn:round](https://www.w3.org/TR/xpath-functions-31/#func-round) #[inline] - pub fn round(&self) -> Self { + pub fn round(self) -> Self { let value = self.value / DECIMAL_PART_POW_MINUS_ONE; Self { value: if value >= 0 { @@ -172,7 +172,7 @@ impl Decimal { /// [fn:ceiling](https://www.w3.org/TR/xpath-functions-31/#func-ceiling) #[inline] - pub fn ceil(&self) -> Self { + pub fn ceil(self) -> Self { Self { value: if self.value >= 0 && self.value % DECIMAL_PART_POW != 0 { (self.value / DECIMAL_PART_POW + 1) * DECIMAL_PART_POW @@ -184,7 +184,7 @@ impl Decimal { /// [fn:floor](https://www.w3.org/TR/xpath-functions-31/#func-floor) #[inline] - pub fn floor(&self) -> Self { + pub fn floor(self) -> Self { Self { value: if self.value >= 0 || self.value % DECIMAL_PART_POW == 0 { (self.value / DECIMAL_PART_POW) * DECIMAL_PART_POW @@ -195,23 +195,23 @@ impl Decimal { } #[inline] - pub const fn is_negative(&self) -> bool { + pub const fn is_negative(self) -> bool { self.value < 0 } #[inline] - pub const fn is_positive(&self) -> bool { + pub const fn is_positive(self) -> bool { self.value > 0 } /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self == other } #[inline] - pub(super) const fn as_i128(&self) -> i128 { + pub(super) const fn as_i128(self) -> i128 { self.value / DECIMAL_PART_POW } diff --git a/lib/oxsdatatypes/src/double.rs b/lib/oxsdatatypes/src/double.rs index b1465c9e..64d3c786 100644 --- a/lib/oxsdatatypes/src/double.rs +++ b/lib/oxsdatatypes/src/double.rs @@ -71,7 +71,7 @@ impl Double { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self.value.to_ne_bytes() == other.value.to_ne_bytes() } @@ -291,9 +291,9 @@ mod tests { #[test] fn is_identical_with() { - assert!(Double::from(0.).is_identical_with(&Double::from(0.))); - assert!(Double::NAN.is_identical_with(&Double::NAN)); - assert!(!Double::from(-0.).is_identical_with(&Double::from(0.))); + assert!(Double::from(0.).is_identical_with(Double::from(0.))); + assert!(Double::NAN.is_identical_with(Double::NAN)); + assert!(!Double::from(-0.).is_identical_with(Double::from(0.))); } #[test] diff --git a/lib/oxsdatatypes/src/duration.rs b/lib/oxsdatatypes/src/duration.rs index 96faec7b..14ea6aac 100644 --- a/lib/oxsdatatypes/src/duration.rs +++ b/lib/oxsdatatypes/src/duration.rs @@ -35,47 +35,47 @@ impl Duration { /// [fn:years-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-years-from-duration) #[inline] - pub fn years(&self) -> i64 { + pub fn years(self) -> i64 { self.year_month.years() } /// [fn:months-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-months-from-duration) #[inline] - pub fn months(&self) -> i64 { + pub fn months(self) -> i64 { self.year_month.months() } /// [fn:days-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-days-from-duration) #[inline] - pub fn days(&self) -> i64 { + pub fn days(self) -> i64 { self.day_time.days() } /// [fn:hours-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-duration) #[inline] - pub fn hours(&self) -> i64 { + pub fn hours(self) -> i64 { self.day_time.hours() } /// [fn:minutes-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-duration) #[inline] - pub fn minutes(&self) -> i64 { + pub fn minutes(self) -> i64 { self.day_time.minutes() } /// [fn:seconds-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-duration) #[inline] - pub fn seconds(&self) -> Decimal { + pub fn seconds(self) -> Decimal { self.day_time.seconds() } #[inline] - pub(super) const fn all_months(&self) -> i64 { + pub(super) const fn all_months(self) -> i64 { self.year_month.all_months() } #[inline] - pub(super) const fn all_seconds(&self) -> Decimal { + pub(super) const fn all_seconds(self) -> Decimal { self.day_time.all_seconds() } @@ -89,7 +89,7 @@ impl Duration { /// [op:add-yearMonthDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-yearMonthDurations) and [op:add-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDurations) #[inline] - pub fn checked_add(&self, rhs: impl Into) -> Option { + pub fn checked_add(self, rhs: impl Into) -> Option { let rhs = rhs.into(); Some(Self { year_month: self.year_month.checked_add(rhs.year_month)?, @@ -99,7 +99,7 @@ impl Duration { /// [op:subtract-yearMonthDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-yearMonthDurations) and [op:subtract-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDurations) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { let rhs = rhs.into(); Some(Self { year_month: self.year_month.checked_sub(rhs.year_month)?, @@ -108,7 +108,7 @@ impl Duration { } #[inline] - pub fn checked_neg(&self) -> Option { + pub fn checked_neg(self) -> Option { Some(Self { year_month: self.year_month.checked_neg()?, day_time: self.day_time.checked_neg()?, @@ -117,7 +117,7 @@ impl Duration { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self == other } } @@ -308,7 +308,7 @@ impl YearMonthDuration { } #[inline] - pub fn checked_neg(&self) -> Option { + pub fn checked_neg(self) -> Option { Some(Self { months: self.months.checked_neg()?, }) @@ -316,7 +316,7 @@ impl YearMonthDuration { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self == other } } @@ -428,32 +428,32 @@ impl DayTimeDuration { /// [fn:days-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-days-from-duration) #[allow(clippy::cast_possible_truncation)] #[inline] - pub fn days(&self) -> i64 { + pub fn days(self) -> i64 { (self.seconds.as_i128() / 86400) as i64 } /// [fn:hours-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-hours-from-duration) #[allow(clippy::cast_possible_truncation)] #[inline] - pub fn hours(&self) -> i64 { + pub fn hours(self) -> i64 { ((self.seconds.as_i128() % 86400) / 3600) as i64 } /// [fn:minutes-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-minutes-from-duration) #[allow(clippy::cast_possible_truncation)] #[inline] - pub fn minutes(&self) -> i64 { + pub fn minutes(self) -> i64 { ((self.seconds.as_i128() % 3600) / 60) as i64 } /// [fn:seconds-from-duration](https://www.w3.org/TR/xpath-functions-31/#func-seconds-from-duration) #[inline] - pub fn seconds(&self) -> Decimal { + pub fn seconds(self) -> Decimal { self.seconds.checked_rem(60).unwrap() } #[inline] - pub(super) const fn all_seconds(&self) -> Decimal { + pub(super) const fn all_seconds(self) -> Decimal { self.seconds } @@ -464,7 +464,7 @@ impl DayTimeDuration { /// [op:add-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-add-dayTimeDurations) #[inline] - pub fn checked_add(&self, rhs: impl Into) -> Option { + pub fn checked_add(self, rhs: impl Into) -> Option { let rhs = rhs.into(); Some(Self { seconds: self.seconds.checked_add(rhs.seconds)?, @@ -473,7 +473,7 @@ impl DayTimeDuration { /// [op:subtract-dayTimeDurations](https://www.w3.org/TR/xpath-functions-31/#func-subtract-dayTimeDurations) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { let rhs = rhs.into(); Some(Self { seconds: self.seconds.checked_sub(rhs.seconds)?, @@ -481,7 +481,7 @@ impl DayTimeDuration { } #[inline] - pub fn checked_neg(&self) -> Option { + pub fn checked_neg(self) -> Option { Some(Self { seconds: self.seconds.checked_neg()?, }) @@ -489,7 +489,7 @@ impl DayTimeDuration { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self == other } } diff --git a/lib/oxsdatatypes/src/float.rs b/lib/oxsdatatypes/src/float.rs index 7f7b979b..86616a24 100644 --- a/lib/oxsdatatypes/src/float.rs +++ b/lib/oxsdatatypes/src/float.rs @@ -71,7 +71,7 @@ impl Float { /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self.value.to_ne_bytes() == other.value.to_ne_bytes() } @@ -281,9 +281,9 @@ mod tests { #[test] fn is_identical_with() { - assert!(Float::from(0.).is_identical_with(&Float::from(0.))); - assert!(Float::NAN.is_identical_with(&Float::NAN)); - assert!(!Float::from(-0.).is_identical_with(&Float::from(0.))); + assert!(Float::from(0.).is_identical_with(Float::from(0.))); + assert!(Float::NAN.is_identical_with(Float::NAN)); + assert!(!Float::from(-0.).is_identical_with(Float::from(0.))); } #[test] diff --git a/lib/oxsdatatypes/src/integer.rs b/lib/oxsdatatypes/src/integer.rs index d3b5fbc9..87d2dbd7 100644 --- a/lib/oxsdatatypes/src/integer.rs +++ b/lib/oxsdatatypes/src/integer.rs @@ -28,7 +28,7 @@ impl Integer { /// [op:numeric-add](https://www.w3.org/TR/xpath-functions-31/#func-numeric-add) #[inline] - pub fn checked_add(&self, rhs: impl Into) -> Option { + pub fn checked_add(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_add(rhs.into().value)?, }) @@ -36,7 +36,7 @@ impl Integer { /// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions-31/#func-numeric-subtract) #[inline] - pub fn checked_sub(&self, rhs: impl Into) -> Option { + pub fn checked_sub(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_sub(rhs.into().value)?, }) @@ -44,7 +44,7 @@ impl Integer { /// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions-31/#func-numeric-multiply) #[inline] - pub fn checked_mul(&self, rhs: impl Into) -> Option { + pub fn checked_mul(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_mul(rhs.into().value)?, }) @@ -52,7 +52,7 @@ impl Integer { /// [op:numeric-divide](https://www.w3.org/TR/xpath-functions-31/#func-numeric-divide) #[inline] - pub fn checked_div(&self, rhs: impl Into) -> Option { + pub fn checked_div(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_div(rhs.into().value)?, }) @@ -60,14 +60,14 @@ impl Integer { /// [op:numeric-mod](https://www.w3.org/TR/xpath-functions-31/#func-numeric-mod) #[inline] - pub fn checked_rem(&self, rhs: impl Into) -> Option { + pub fn checked_rem(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_rem(rhs.into().value)?, }) } #[inline] - pub fn checked_rem_euclid(&self, rhs: impl Into) -> Option { + pub fn checked_rem_euclid(self, rhs: impl Into) -> Option { Some(Self { value: self.value.checked_rem_euclid(rhs.into().value)?, }) @@ -75,7 +75,7 @@ impl Integer { /// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions-31/#func-numeric-unary-minus) #[inline] - pub fn checked_neg(&self) -> Option { + pub fn checked_neg(self) -> Option { Some(Self { value: self.value.checked_neg()?, }) @@ -83,25 +83,25 @@ impl Integer { /// [fn:abs](https://www.w3.org/TR/xpath-functions-31/#func-abs) #[inline] - pub const fn abs(&self) -> Self { + pub const fn abs(self) -> Self { Self { value: self.value.abs(), } } #[inline] - pub const fn is_negative(&self) -> bool { + pub const fn is_negative(self) -> bool { self.value < 0 } #[inline] - pub const fn is_positive(&self) -> bool { + pub const fn is_positive(self) -> bool { self.value > 0 } /// Checks if the two values are [identical](https://www.w3.org/TR/xmlschema11-2/#identity). #[inline] - pub fn is_identical_with(&self, other: &Self) -> bool { + pub fn is_identical_with(self, other: Self) -> bool { self == other } diff --git a/lib/src/sparql/model.rs b/lib/src/sparql/model.rs index d7c69ca7..9525a260 100644 --- a/lib/src/sparql/model.rs +++ b/lib/src/sparql/model.rs @@ -167,6 +167,7 @@ pub struct QuerySolutionIter { } impl QuerySolutionIter { + #[allow(clippy::rc_buffer)] pub fn new( variables: Rc>, iter: impl Iterator>, EvaluationError>> + 'static, diff --git a/lib/src/storage/numeric_encoder.rs b/lib/src/storage/numeric_encoder.rs index 73b00fe3..92fc1b5b 100644 --- a/lib/src/storage/numeric_encoder.rs +++ b/lib/src/storage/numeric_encoder.rs @@ -183,24 +183,24 @@ impl PartialEq for EncodedTerm { }, ) => value_id_a == value_id_b && datatype_id_a == datatype_id_b, (Self::BooleanLiteral(a), Self::BooleanLiteral(b)) => a == b, - (Self::FloatLiteral(a), Self::FloatLiteral(b)) => a.is_identical_with(b), - (Self::DoubleLiteral(a), Self::DoubleLiteral(b)) => a.is_identical_with(b), - (Self::IntegerLiteral(a), Self::IntegerLiteral(b)) => a.is_identical_with(b), - (Self::DecimalLiteral(a), Self::DecimalLiteral(b)) => a.is_identical_with(b), - (Self::DateTimeLiteral(a), Self::DateTimeLiteral(b)) => a.is_identical_with(b), - (Self::TimeLiteral(a), Self::TimeLiteral(b)) => a.is_identical_with(b), - (Self::DateLiteral(a), Self::DateLiteral(b)) => a.is_identical_with(b), - (Self::GYearMonthLiteral(a), Self::GYearMonthLiteral(b)) => a.is_identical_with(b), - (Self::GYearLiteral(a), Self::GYearLiteral(b)) => a.is_identical_with(b), - (Self::GMonthDayLiteral(a), Self::GMonthDayLiteral(b)) => a.is_identical_with(b), - (Self::GMonthLiteral(a), Self::GMonthLiteral(b)) => a.is_identical_with(b), - (Self::GDayLiteral(a), Self::GDayLiteral(b)) => a.is_identical_with(b), - (Self::DurationLiteral(a), Self::DurationLiteral(b)) => a.is_identical_with(b), + (Self::FloatLiteral(a), Self::FloatLiteral(b)) => a.is_identical_with(*b), + (Self::DoubleLiteral(a), Self::DoubleLiteral(b)) => a.is_identical_with(*b), + (Self::IntegerLiteral(a), Self::IntegerLiteral(b)) => a.is_identical_with(*b), + (Self::DecimalLiteral(a), Self::DecimalLiteral(b)) => a.is_identical_with(*b), + (Self::DateTimeLiteral(a), Self::DateTimeLiteral(b)) => a.is_identical_with(*b), + (Self::TimeLiteral(a), Self::TimeLiteral(b)) => a.is_identical_with(*b), + (Self::DateLiteral(a), Self::DateLiteral(b)) => a.is_identical_with(*b), + (Self::GYearMonthLiteral(a), Self::GYearMonthLiteral(b)) => a.is_identical_with(*b), + (Self::GYearLiteral(a), Self::GYearLiteral(b)) => a.is_identical_with(*b), + (Self::GMonthDayLiteral(a), Self::GMonthDayLiteral(b)) => a.is_identical_with(*b), + (Self::GMonthLiteral(a), Self::GMonthLiteral(b)) => a.is_identical_with(*b), + (Self::GDayLiteral(a), Self::GDayLiteral(b)) => a.is_identical_with(*b), + (Self::DurationLiteral(a), Self::DurationLiteral(b)) => a.is_identical_with(*b), (Self::YearMonthDurationLiteral(a), Self::YearMonthDurationLiteral(b)) => { - a.is_identical_with(b) + a.is_identical_with(*b) } (Self::DayTimeDurationLiteral(a), Self::DayTimeDurationLiteral(b)) => { - a.is_identical_with(b) + a.is_identical_with(*b) } (Self::Triple(a), Self::Triple(b)) => a == b, (_, _) => false,