Lifetime game, trying to think of good questions?

I'm working on a proc-macro-workshop like "game/walkthrough" for lifetimes The Game of Life...times.

If anyone has good examples of interesting lifetime problems that'd be much appreciated.

I need to add a README but the workflow is

git clone
cd rust-adventure
cargo run

after cargo run open the file in the answers directory
it generates an answers directory with a rust file to fix the lifetime issue. Once the file compiles it deletes it and generates the next question.

I wondered if making it available via cargo install and fetching the questions would be preferable to cloning, although being in the root and generating the folders/files might be a bit odd.

1 Like

You expect me to spend minutes/hours/days solving a problem to watch the answer be erased before my eyes as soon as I find it.
The next thing I've done after solving question 1 is not answer question 2 but delete the whole thing.

More seriously, it doesn't seem to be the right thing to do, sometimes when trying stuff, it works and I have to go back to understand why exactly. Plus people might want to share their solution if there are multiple ones at some point.

Also, I'm on Windows 10 and the home/... directories was in C: while rust-adventure is not there at all, this is very unexpected.

1 Like

That is a completely valid point I wasn't sure how to handle moving forward in the excersize. Leaving the answers makes more sense.

You git cloned while in C: and it didn't clone it into the C folder? Am I understanding that correctly? When run the program uses env::current_dir if that makes a difference.

Sorry about not formatting anything I'm on a phone

I git cloned in C:\Users\Leudz\Dev then I changed to the newly created rust-adventure folder before calling cargo run but I got C:\home\.... I tried twice and same result.

The issue is in QuestionHolder::new, I might be wrong but I think you hardcoded the answer folder in the archive.

1 Like

Well I was doing something dumb its fixed now so if anyone has lifetime ideas or other thoughts much appreciated lifetimes.

Thank you @leudz for trying it out you were completely right sorry.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.