Skip to content

Commit

Permalink
No need to explicitly name trait methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed May 14, 2024
1 parent 7ac8bff commit 46fc053
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion minijinja/src/value/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ type_erase! {
fn render(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result;

impl fmt::Debug {
fn fmt[debug_fmt](&self, f: &mut fmt::Formatter<'_>) -> fmt::Result;
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions minijinja/src/value/type_erase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ macro_rules! type_erase {
$(
impl $impl_name:path {
$(
fn $f_impl:ident[$f_impl_vtable:ident](
fn $f_impl:ident(
&self $(, $p_impl:ident: $t_impl:ty $(,)?)*
) $(-> $r_impl:ty)?;
)*
Expand All @@ -24,7 +24,7 @@ macro_rules! type_erase {
const _: () = {
struct VTable {
$($f: fn(*const (), $($p: $t),*) $(-> $r)?,)*
$($($f_impl_vtable: fn(*const (), $($p_impl: $t_impl),*) $(-> $r_impl)?,)*)*
$($($f_impl: fn(*const (), $($p_impl: $t_impl),*) $(-> $r_impl)?,)*)*
__type_id: fn() -> std::any::TypeId,
__type_name: fn() -> &'static str,
__drop: fn(*const ()),
Expand All @@ -49,7 +49,7 @@ macro_rules! type_erase {
},
)*
$($(
$f_impl_vtable: |ptr, $($p_impl),*| unsafe {
$f_impl: |ptr, $($p_impl),*| unsafe {
let arc = std::sync::Arc::<T>::from_raw(ptr as *const T);
let v = <T as $impl_name>::$f_impl(&*arc, $($p_impl),*);
std::mem::forget(arc);
Expand Down Expand Up @@ -147,7 +147,7 @@ macro_rules! type_erase {
impl $impl_name for $erased_t_name {
$(
fn $f_impl(&self, $($p_impl: $t_impl),*) $(-> $r_impl)? {
(vt(self).$f_impl_vtable)(self.ptr, $($p_impl),*)
(vt(self).$f_impl)(self.ptr, $($p_impl),*)
}
)*
}
Expand Down

0 comments on commit 46fc053

Please sign in to comment.