-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from popzxc/types-bounds
Allow trait bounds on generic params in the trait alias
- Loading branch information
Showing
5 changed files
with
57 additions
and
5 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,9 @@ | ||
# Changelog | ||
|
||
## Version 0.2.0 (202x-xx-xx) | ||
|
||
- Support for trait bounds on generic params for the alias was added. | ||
|
||
## Version 0.1.0 (2021-04-18) | ||
|
||
- Initial crate implementation. |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "trait-set" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = ["Igor Aleksanov <[email protected]>"] | ||
edition = "2018" | ||
repository = "https://github.com/popzxc/trait-set" | ||
|
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
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
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,25 @@ | ||
//! Checks that trait bounds can be applied to the generic arguments | ||
//! of an alias. | ||
use trait_set::trait_set; | ||
|
||
pub trait GenericTrait<T> { | ||
fn new(t: T) -> Self; | ||
} | ||
|
||
impl GenericTrait<u8> for u8 { | ||
fn new(t: u8) -> u8 { | ||
t | ||
} | ||
} | ||
|
||
trait_set! { | ||
pub(crate) trait GenericIteratorSendableT<T: Send> = Iterator<Item = T>; | ||
} | ||
|
||
fn test_set<T: GenericIteratorSendableT<u8>>(_arg: T) {} | ||
|
||
fn main() { | ||
test_set([10u8, 20, 30].as_ref().iter().copied()); | ||
test_set(b"abcde".iter().copied()); | ||
} |