-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimal example of bug(?) with higher-ranked trait bounds
See: https://github.com/gnu3ra/bobot/tree/broken_higher_ranked_trait_bounds rust-lang/rust#70263
- Loading branch information
0 parents
commit ac63bb6
Showing
4 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "hrtb_test" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
futures = "0.3.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use futures::Future; | ||
trait TestFn<'a>: Send + Sync { | ||
type Fut: Future<Output = ()>; | ||
fn call(self, v: &'a i64) -> Self::Fut; | ||
} | ||
|
||
impl<'a, F, Fut> TestFn<'a> for F | ||
where | ||
F: FnOnce(&'a i64) -> Fut + Send + Sync, | ||
Fut: Future<Output = ()>, | ||
{ | ||
type Fut = Fut; | ||
|
||
fn call(self, v: &'a i64) -> Self::Fut { | ||
self(v) | ||
} | ||
} | ||
|
||
async fn test<F>(func: F) | ||
where | ||
F: for<'a> TestFn<'a>, | ||
{ | ||
func.call(&3).await | ||
} | ||
|
||
async fn main_async() { | ||
test(|v| async move { | ||
println!("works! {} ", v); | ||
}) | ||
.await; | ||
} | ||
|
||
fn main() { | ||
futures::executor::block_on(main_async()); | ||
} |