-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implementation of RefType
is not general enough
#1
Comments
I'm reading https://doc.rust-lang.org/nightly/core/pin/index.html, it will take me a while. My goal was: Something like https://doc.rust-lang.org/nightly/core/pin/index.html#example-self-referential-struct, but not in a |
Hi, and thanks for your interest in Selfie! Even though you closed the issue I'm still going to answer your initial question, I think this will help, and also I believe it highlights weaknesses in the documentation. For the part about putting a Selfie in a struct, here is how it would look like (using a Box for simplicity): pub struct Outer {
inner: Selfie<'static, Box<[u8; 8]>, Ref<[u8]>>,
} The generic lifetime of a You can also move that struct (both As for a pub struct Outer<'a> {
inner: Selfie<'a, &'a [u8; 8], Ref<[u8]>>,
}
fn do_thing_with_outer(outer: Outer) { todo!() }
fn main() {
let not_moving_data = [0; 8];
let outer = Outer {
inner: Selfie::new(Pin::new(¬_moving_data), |data| &data[4..])
};
// Outer can be moved here, no problem as long as not_moving_data is still alive
do_thing_with_outer(outer);
} Hope this helps! 🙂 |
Thank you. I realized that I don't need lazy/interior mutability for now. But I'll remember Thank you also for MIRI GitHub actions config. I'm using it with my project to check |
Salut Adrien,
Thank you for
selfie
.This, I believe, is not an issue with
selfie
, but rather my understanding ofPin
, or a difficulty with Rust types/lifetimes. Instead of having a selfie-based type only used for a local variable (and hence inferred), I'd like to use it as a part of a largerstruct
(orenum
with data field(s)). Is that possible, and how?I understand that the whole
struct
/enum
could not be moved. Would the wholestruct/enum
have to be used insidePin
, or could it be an ordinarystruct
(orenum
) but not aCopy
and with customclone()
?which fails with:
implementation of
RefTypeis not general enough
The text was updated successfully, but these errors were encountered: