Skip to content

Commit

Permalink
non-tuple Fn implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Sep 28, 2023
1 parent fb7662c commit d78686f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
27 changes: 9 additions & 18 deletions leptos/src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,34 +146,25 @@ where
}

#[cfg(feature = "nightly")]
impl<In, Out> FnOnce<In> for Callback<In, Out>
where
In: std::marker::Tuple,
{
impl<In, Out> FnOnce<(In,)> for Callback<In, Out> {
type Output = Out;

extern "rust-call" fn call_once(self, args: In) -> Self::Output {
Callable::call(&self, args)
extern "rust-call" fn call_once(self, args: (In,)) -> Self::Output {
Callable::call(&self, args.0)
}
}

#[cfg(feature = "nightly")]
impl<In, Out> FnMut<In> for Callback<In, Out>
where
In: std::marker::Tuple,
{
extern "rust-call" fn call_mut(&mut self, args: In) -> Self::Output {
Callable::call(&*self, args)
impl<In, Out> FnMut<(In,)> for Callback<In, Out> {
extern "rust-call" fn call_mut(&mut self, args: (In,)) -> Self::Output {
Callable::call(&*self, args.0)
}
}

#[cfg(feature = "nightly")]
impl<In, Out> Fn<In> for Callback<In, Out>
where
In: std::marker::Tuple,
{
extern "rust-call" fn call(&self, args: In) -> Self::Output {
Callable::call(self, args)
impl<In, Out> Fn<(In,)> for Callback<In, Out> {
extern "rust-call" fn call(&self, args: (In,)) -> Self::Output {
Callable::call(self, args.0)
}
}

Expand Down
1 change: 0 additions & 1 deletion leptos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#![cfg_attr(feature = "nightly", feature(unboxed_closures))]
#![cfg_attr(feature = "nightly", feature(negative_impls))]
#![cfg_attr(feature = "nightly", feature(auto_traits))]
#![cfg_attr(feature = "nightly", feature(tuple_trait))]
//! # About Leptos
//!
//! Leptos is a full-stack framework for building web applications in Rust. You can use it to build
Expand Down

0 comments on commit d78686f

Please sign in to comment.