Rust cannot resolve trait bound for associated type #81436
Labels
A-associated-items
Area: Associated items such as associated types and consts.
A-lifetimes
Area: lifetime related
A-traits
Area: Trait system
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I am trying to implement the Family design pattern as per this post by Luka and this one by Niko.
My goal is to abstract db transactions thanks to a
Db
trait that exposes read and write transaction. TheDb
trait have 2 associated types,Writer
andReader
that define the operations that can be done on them. Ultimately, by being generic over theReader
andWriter
types, I hope to be able to mock the actual db operations.I tried this code:
This is what I have come up with:
Code
and there on the playground https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=01bba28ff362a5f59da198b38a127d0e
I expect it to compile without error, since
MapKvStoreDb
implementsDb<Writer = MapKvStoreDbWriterTxn, Reader = MapKvStoreDbReaderTxn>
, andMapKvStoreDbReaderTxn
implementTxnFamily
whoseOut
implementsKvStoreDbReader
, and same forMapKvStoreDbWriterTxn
.Instead, I get this error:
The text was updated successfully, but these errors were encountered: