Skip to content

Commit 70a8173

Browse files
committed
using .rep() instead of .0
1 parent 5d265ef commit 70a8173

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

rust/functora-tagged/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ where
3232
.map(|rep| Tagged(rep, PhantomData))
3333
.map_err(RefineError)
3434
}
35-
pub fn rep(self) -> Rep {
36-
self.0
35+
pub fn rep(&self) -> &Rep {
36+
&self.0
3737
}
3838
}
3939

@@ -42,7 +42,7 @@ where
4242
Rep: Refine<Tag> + PartialEq,
4343
{
4444
fn eq(&self, other: &Self) -> bool {
45-
self.0 == other.0
45+
self.rep() == other.rep()
4646
}
4747
}
4848

@@ -59,7 +59,7 @@ where
5959
&self,
6060
other: &Self,
6161
) -> Option<std::cmp::Ordering> {
62-
self.0.partial_cmp(&other.0)
62+
self.rep().partial_cmp(other.rep())
6363
}
6464
}
6565

@@ -68,7 +68,7 @@ where
6868
Rep: Refine<Tag> + Ord,
6969
{
7070
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
71-
self.0.cmp(&other.0)
71+
self.rep().cmp(other.rep())
7272
}
7373
}
7474

@@ -111,7 +111,7 @@ where
111111
where
112112
S: serde::Serializer,
113113
{
114-
self.0.serialize(serializer)
114+
self.rep().serialize(serializer)
115115
}
116116
}
117117

@@ -151,7 +151,7 @@ mod diesel_impl {
151151
type Expression =
152152
<Rep as AsExpression<ST>>::Expression;
153153
fn as_expression(self) -> Self::Expression {
154-
self.0.as_expression()
154+
self.rep().clone().as_expression()
155155
}
156156
}
157157

@@ -163,7 +163,7 @@ mod diesel_impl {
163163
type Expression =
164164
<Rep as AsExpression<ST>>::Expression;
165165
fn as_expression(self) -> Self::Expression {
166-
self.0.clone().as_expression()
166+
self.rep().clone().as_expression()
167167
}
168168
}
169169

@@ -178,7 +178,7 @@ mod diesel_impl {
178178
&'a self,
179179
out: &mut Output<'a, '_, DB>,
180180
) -> diesel::serialize::Result {
181-
self.0.to_sql(out)
181+
self.rep().to_sql(out)
182182
}
183183
}
184184

rust/functora-tagged/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct UserIdError;
4343
impl Refine<UserIdTag> for NonEmpty<String> {
4444
type RefineErrorRep = UserIdError;
4545
fn refine(self) -> Result<Self, Self::RefineErrorRep> {
46-
let txt = self.clone().rep();
46+
let txt = self.rep();
4747
if txt.starts_with("user_") && txt.len() > 5 {
4848
Ok(self)
4949
} else {

0 commit comments

Comments
 (0)