Readit News logoReadit News
janquo commented on Rust's Block Pattern   notgull.net/block-pattern... · Posted by u/zdw
nemo1618 · 2 months ago
Conversely, I use this "block pattern" a lot, and sometimes it causes lifetime issues:

    let foo: &[SomeType] = {
        let mut foo = vec![];
        // ... initialize foo ...
        &foo
    };
This doesn't work: the memory is owned by the Vec, whose lifetime is tied to the block, so the slice is invalid outside of that block. To be fair, it's probably best to just make foo a Vec, and turn it into a slice where needed.

janquo · 2 months ago
There is some experimental work for that here I believe:

https://doc.rust-lang.org/beta/unstable-book/language-featur...

AFAIU it essentially creates a variable in inner scope but defers drop to the outer scope so that you can return the reference

janquo commented on Jujutsu worktrees are convenient (2024)   shaddy.dev/notes/jj-workt... · Posted by u/nvader
gcr · 2 months ago
Why are you using git tools within collocated jj repositories? I never understood that use case tbh
janquo · 2 months ago
Some company tooling / git oneliners from internet / and probably most relevant for me is git plugins for neovim / some personal scripts I would have rewrite to work both in .git and .jj repos
janquo commented on Jujutsu worktrees are convenient (2024)   shaddy.dev/notes/jj-workt... · Posted by u/nvader
janquo · 2 months ago
It's not really usable to me as the workspace folder doesn't have .git in it, even though original repo is collocated and hence the git tools don't work there. I am forced to use git work trees with separate collocated JJ repo each.
janquo commented on Sleep on it: How the brain processes many experiences, even when 'offline'   news.yale.edu/2024/08/14/... · Posted by u/PaulHoule
janquo · a year ago
I am wondering if we should be paid for consistent sleep time
janquo commented on Ask HN: Where to find open-source house plans?    · Posted by u/tsingy
janquo · 2 years ago
Polish government has released free plans for special <70 squared m houses that do not need permission to be built. I'm afraid you have to fill in the form with fake info to download them. https://www.gunb.gov.pl/projekty-architektoniczno-budowlane

u/janquo

KarmaCake day5August 23, 2023View Original