Skip to content

is it possible to use yoke to implement a subset borrowing pattern? #4215

Answered by sffc
tamird asked this question in Q&A
Discussion options

You must be logged in to vote

The data should be owned by the cart and borrowed by the Yokeable.

So you want something more like this:

struct OwnedSuperSet {
  a: MyStructOne,
  b: MyStructTwo,
  c: MyStructThree,
}

#[derive(Yokeable)]
struct BorrowedSuperSet<'a> {
  a: &'a MyStructOne,
  b: &'a MyStructTwo,
  c: &'a MyStructThree,
}

#[derive(Yokeable)]
struct BorrowedSubSet<'a> {
  a: &'a MyStructOne,
  c: &'a MyStructThree,
}

// Start here:
Yoke<BorrowedSuperSet<'static>, Rc<OwnedSuperSet>>

// map_project to here:
Yoke<BorrowedSubSet<'static>, Rc<OwnedSuperSet>>

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@tamird
Comment options

@Manishearth
Comment options

Answer selected by tamird
Comment options

You must be logged in to vote
3 replies
@tamird
Comment options

@Manishearth
Comment options

@tamird
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #4214 on October 24, 2023 16:45.