Ancestors

Toot

Written by yosh on 2025-01-25 at 01:03

Spent 45 mins earlier today writing a new (ish) implementation of a scope guard impl:

https://docs.rs/mini-scopeguard

This feels like something that should exist in the stdlib, and I think I might submit this for inclusion as core::drop::Guard (or some variation on that name).

=> More informations about this toot | More toots from yosh@toot.yosh.is

Descendants

Written by robinm on 2025-01-25 at 01:26

@yosh I was trying to read the source code to understand how it works, and noticed this comment:

https://docs.rs/mini-scopeguard/latest/src/mini_scopeguard/lib.rs.html#150

test copied from .../latest/...#1-595

I think you should link to an exact version, so that the line numbers don't drift over time

=> More informations about this toot | More toots from robinm@fosstodon.org

Written by robinm on 2025-01-25 at 01:31

@yosh That being said, I have no clue how it works. I don't understand how the first argument of new() can be taken by value and still be used after

=> More informations about this toot | More toots from robinm@fosstodon.org

Written by yosh on 2025-01-25 at 01:53

@robinm the magic is in the deref impls. This is the same trait that makes e.g. Mutex, Box, Arc, etc work

=> More informations about this toot | More toots from yosh@toot.yosh.is

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113886303887642202
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
258.858612 milliseconds
Gemini-to-HTML Time
0.693837 milliseconds

This content has been proxied by September (ba2dc).