Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/azriel91/assoc_type_params

Experiment using single type with associated types to track type params.
https://github.com/azriel91/assoc_type_params

Last synced: about 1 month ago
JSON representation

Experiment using single type with associated types to track type params.

Awesome Lists containing this project

README

        

# Assoc Type Params

Experiment using single type with associated types to track type params.

Instead of:

```rust
struct CmdCtx {
input: Input,
output: Output,
marker: std::marker::PhantomData,
}

fn borrows_cmd_ctx(
ctx: &mut CmdCtx,
// other params
) -> Result<(), Error> {
todo!()
}

fn pass_cmd_ctx_around(
cmd_ctx: &mut CmdCtx,
) {
todo!()
}
```

We want something like:

```rust
struct CmdCtx {
input: Types::Input,
output: Types::Output,
}

fn borrows_cmd_ctx(
ctx: &mut CmdCtx,
// other params
) -> Result<(), Types::Error> {
todo!()
}

fn pass_cmd_ctx_around(
cmd_ctx: &mut CmdCtx,
) {
todo!()
}
```