Skip to content

Commit e6ec065

Browse files
committed
Leak copy which allow us to always use by_value
1 parent c82bcdd commit e6ec065

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/fraction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ where
7878
{
7979
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
8080
let (sign, numerator, denominator) =
81-
extract_sign(self.numerator.to_impl(), self.denominator.to_impl(), f);
81+
extract_sign(self.numerator.into_impl(), self.denominator.into_impl(), f);
8282

8383
if let Some(sign) = sign {
8484
f.write_char(sign)?;

src/integer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ macro_rules! impl_signed_integer {
158158
impl crate::ToIntegerImpl for $ty {
159159
type Impl = $ty;
160160

161-
fn to_impl(&self) -> $ty {
162-
*self
161+
fn into_impl(self) -> $ty {
162+
self
163163
}
164164
}
165165

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
/// }
7171
/// ```
7272
#[allow(private_bounds)]
73-
pub trait Integer: ToIntegerImpl {}
73+
pub trait Integer: ToIntegerImpl + Copy {}
7474

7575
/// Abstraction over signed integer types.
7676
pub trait SignedInteger: Integer {}
@@ -82,7 +82,7 @@ pub trait UnsignedInteger: Integer {}
8282
pub(crate) trait ToIntegerImpl {
8383
type Impl: crate::integer::IntegerImpl<Public = Self>;
8484

85-
fn to_impl(&self) -> Self::Impl;
85+
fn into_impl(self) -> Self::Impl;
8686
}
8787

8888
mod sub_superscript;

src/seven_segment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ where
5050
T: UnsignedInteger,
5151
{
5252
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53-
fmt_seven_segment::<_, <T::Impl as IntegerImpl>::BaseTwo>(self.0.to_impl(), f)
53+
fmt_seven_segment::<_, <T::Impl as IntegerImpl>::BaseTwo>(self.0.into_impl(), f)
5454
}
5555
}
5656

@@ -59,7 +59,7 @@ where
5959
T: UnsignedInteger,
6060
{
6161
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62-
fmt_seven_segment::<_, <T::Impl as IntegerImpl>::BaseTen>(self.0.to_impl(), f)
62+
fmt_seven_segment::<_, <T::Impl as IntegerImpl>::BaseTen>(self.0.into_impl(), f)
6363
}
6464
}
6565

src/sub_superscript.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4444
fmt_number_with_base_and_digits::<_, <T::Impl as IntegerImpl>::BaseTen>(
4545
f,
46-
self.0.to_impl(),
46+
self.0.into_impl(),
4747
'⁺',
4848
'⁻',
4949
&['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹'],
@@ -58,7 +58,7 @@ where
5858
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5959
fmt_number_with_base_and_digits::<_, <T::Impl as IntegerImpl>::BaseTwo>(
6060
f,
61-
self.0.to_impl(),
61+
self.0.into_impl(),
6262
'⁺',
6363
'⁻',
6464
&['⁰', '¹'],
@@ -106,7 +106,7 @@ where
106106
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
107107
fmt_number_with_base_and_digits::<_, <T::Impl as IntegerImpl>::BaseTen>(
108108
f,
109-
self.0.to_impl(),
109+
self.0.into_impl(),
110110
'₊',
111111
'₋',
112112
&['₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉'],
@@ -121,7 +121,7 @@ where
121121
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
122122
fmt_number_with_base_and_digits::<_, <T::Impl as IntegerImpl>::BaseTwo>(
123123
f,
124-
self.0.to_impl(),
124+
self.0.into_impl(),
125125
'₊',
126126
'₋',
127127
&['₀', '₁'],

src/tally_marks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ where
3838
T: UnsignedInteger,
3939
{
4040
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41-
fmt_tally_marks(self.0.to_impl(), f)
41+
fmt_tally_marks(self.0.into_impl(), f)
4242
}
4343
}
4444

0 commit comments

Comments
 (0)