https://github.com/nekitdev/trait-aliases
Trait aliases.
https://github.com/nekitdev/trait-aliases
Last synced: about 1 month ago
JSON representation
Trait aliases.
- Host: GitHub
- URL: https://github.com/nekitdev/trait-aliases
- Owner: nekitdev
- License: mit
- Created: 2025-12-24T19:35:47.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-12-27T19:23:01.000Z (about 2 months ago)
- Last Synced: 2025-12-30T02:32:00.577Z (about 2 months ago)
- Language: Rust
- Homepage: https://docs.rs/trait-aliases
- Size: 30.3 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# `trait-aliases`
[![License][License Badge]][License]
[![Version][Version Badge]][Crate]
[![Downloads][Downloads Badge]][Crate]
[![Documentation][Documentation Badge]][Documentation]
[![Test][Test Badge]][Actions]
> *Trait aliases.*
## Installation
### `cargo`
You can add `trait-aliases` as a dependency with the following command:
```console
$ cargo add trait-aliases
```
Or by directly specifying it in the configuration like so:
```toml
[dependencies]
trait-aliases = "0.2.0"
```
Alternatively, you can add it directly from the source:
```toml
[dependencies.trait-aliases]
git = "https://github.com/nekitdev/trait-aliases.git"
```
## Example
> Ever felt tired of writing `T: Send + Sync + 'static` over and over when working with `async`
> in multi-threaded scenarios?
Simply define an alias without blanket implementation boilerplate!
```rust
use trait_aliases::trait_aliases;
trait_aliases! {
/// Working in multi-threaded `async` contexts often requires these.
pub trait SSS = Send + Sync + 'static;
}
```
This crate will generate the `SSS` trait with the provided bounds, and implement it for any type
satisfying them:
```rust
/// Working in multi-threaded `async` contexts often requires these.
pub trait SSS: Send + Sync + 'static {}
/// Blanket implementation of [`SSS`] for all types satisfying its bounds.
impl<__T> SSS for __T where __T: Send + Sync + 'static + ?Sized {}
```
## Note
The `__T` identifier is essential to correct code generation, therefore *any* occurrences
of the reserved identifier will result in compilation errors:
```rust
use trait_aliases::trait_aliases;
trait_aliases! {
trait __T = Sized;
}
```
Fails with the following error:
```text
identifier `__T` is reserved for blanket implementations
```
## Documentation
You can find the documentation [here][Documentation].
## Support
If you need support with the library, you can send an [email][Email].
## Changelog
You can find the changelog [here][Changelog].
## Security Policy
You can find the Security Policy of `trait-aliases` [here][Security].
## Contributing
If you are interested in contributing to `trait-aliases`, make sure to take a look at the
[Contributing Guide][Contributing Guide], as well as the [Code of Conduct][Code of Conduct].
## License
`trait-aliases` is licensed under the MIT License terms. See [License][License] for details.
[Email]: mailto:support@nekit.dev
[Discord]: https://nekit.dev/chat
[Actions]: https://github.com/nekitdev/trait-aliases/actions
[Changelog]: https://github.com/nekitdev/trait-aliases/blob/main/CHANGELOG.md
[Code of Conduct]: https://github.com/nekitdev/trait-aliases/blob/main/CODE_OF_CONDUCT.md
[Contributing Guide]: https://github.com/nekitdev/trait-aliases/blob/main/CONTRIBUTING.md
[Security]: https://github.com/nekitdev/trait-aliases/blob/main/SECURITY.md
[License]: https://github.com/nekitdev/trait-aliases/blob/main/LICENSE
[Crate]: https://crates.io/crates/trait-aliases
[Documentation]: https://docs.rs/trait-aliases
[License Badge]: https://img.shields.io/crates/l/trait-aliases
[Version Badge]: https://img.shields.io/crates/v/trait-aliases
[Downloads Badge]: https://img.shields.io/crates/dr/trait-aliases
[Documentation Badge]: https://img.shields.io/docsrs/trait-aliases
[Test Badge]: https://github.com/nekitdev/trait-aliases/workflows/test/badge.svg