You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently using PkOwned for MultiIndex and UniqueIndex keys. See also related #199, for another attempt to remove PkOwned.
This is what we get when changing the nameMultiIndex to use &[u8] instead of PkOwned (in the indexed_map.rs tests):
Compiling cw-storage-plus v0.5.0 (/usr2/home/mauro/work/cosmwasm-plus/packages/storage-plus)
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
--> packages/storage-plus/src/indexed_map.rs:209:50
|
209 | name: MultiIndex::new(|d, k| (d.name.as_ref(), &*k), "data", "data__name"),
| ^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 209:35...
--> packages/storage-plus/src/indexed_map.rs:209:35
|
209 | name: MultiIndex::new(|d, k| (d.name.as_ref(), &*k), "data", "data__name"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so that reference does not outlive borrowed content
--> packages/storage-plus/src/indexed_map.rs:209:43
|
209 | name: MultiIndex::new(|d, k| (d.name.as_ref(), &*k), "data", "data__name"),
| ^^^^^^
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 207:18...
--> packages/storage-plus/src/indexed_map.rs:207:18
|
207 | fn build_map<'a>() -> IndexedMap<'a, &'a [u8], Data, DataIndexes<'a>> {
| ^^
note: ...so that the expression is assignable
--> packages/storage-plus/src/indexed_map.rs:216:9
|
216 | IndexedMap::new("data", indexes)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `indexed_map::IndexedMap<'a, &'a [u8], _, DataIndexes<'a>>`
found `indexed_map::IndexedMap<'_, &[u8], _, DataIndexes<'_>>`
error: aborting due to previous error
Analyze if we can use &[u8] for keys / subkeys in UniqueIndex and MultiIndex, after resolving these lifetime conflicts.
As a reference, Map allows using &[u8] for keys without issues.
The text was updated successfully, but these errors were encountered:
maurolacy
changed the title
Support life-timed references in UniqueIndex and MultiIndex
Support life-timed references in UniqueIndex and MultiIndex keys
Mar 4, 2021
We're currently using
PkOwned
forMultiIndex
andUniqueIndex
keys. See also related #199, for another attempt to removePkOwned
.This is what we get when changing the
name
MultiIndex
to use&[u8]
instead ofPkOwned
(in theindexed_map.rs
tests):Analyze if we can use
&[u8]
for keys / subkeys inUniqueIndex
andMultiIndex
, after resolving these lifetime conflicts.As a reference,
Map
allows using&[u8]
for keys without issues.The text was updated successfully, but these errors were encountered: