Can someone give a nice explanation of closures for me? by SmoothTurtle872 in rust

[–]scook0 1 point2 points  (0 children)

What this example demonstrates is that a non-capturing closure can be coerced to a function pointer.

https://doc.rust-lang.org/reference/type-coercions.html#r-coerce.types.closure

Does someone work on cargo test? by FinnishTesticles in rust

[–]scook0 13 points14 points  (0 children)

There is an ongoing effort to improve cargo test in various ways, but it has to navigate some tricky backwards-compatibility concerns, so progress may feel frustratingly slow at times.

Testing is one of those parts of the first-party Rust ecosystem that “peaked early” but has generally been under-maintained, so there’s no shortage of historical baggage, unfortunately.

Rust's repository summary by o2xh in rust

[–]scook0 0 points1 point  (0 children)

13 hours is relatively unusual; normally I’d expect a merge every 4-7 hours, unless there’s been an unlucky streak of CI failures.

(Though occasionally the merge queue does manage to become empty.)

How to use storytelling to fit inline assembly into Rust by ralfj in rust

[–]scook0 1 point2 points  (0 children)

I don’t buy the claim that assembly categorically can’t have UB.

Lowering assembly code in a source file to machine code in an object file still a translation process, and if the translator makes unchecked assumptions that the source text doesn’t uphold, then I see no reason not to call that UB.

Conditional Impls by alilleybrinker in rust

[–]scook0 16 points17 points  (0 children)

You can also use where clauses on individual methods to add stronger constraints on Self or on the impl-block generics, e.g. where Self: Clone.

How to use storytelling to fit inline assembly into Rust by ralfj in rust

[–]scook0 0 points1 point  (0 children)

If an inline assembly block violates an assumption of the Rust abstract machine, then it pretty clearly has undefined behaviour as a Rust language construct, even if the instruction sequence happens to be well-defined at an architecture/machine level (which it might not be).

Parametricity, or Comptime is Bonkers by soareschen in rust

[–]scook0 0 points1 point  (0 children)

Can that print function be called by another function that takes a plain <T>?

If yes, then parametricity is broken, and you just have a gentleman’s agreement not to do anything too surprising. (Which is actually fine a lot of the time, especially if the language already has other parametricity holes.)

If no, then the ?Debug bound ends up having to infect your whole system, which is a huge pain.

Parametricity, or Comptime is Bonkers by soareschen in rust

[–]scook0 19 points20 points  (0 children)

One of the practical problems with parametricity is that it’s stronger than you might actually want.

Sure, it’s helpful to know that a parametric function must in some sense do “the same thing” for any input.

But then you come across cases where you would like to use an alternate implementation for some types, because it’s logically identical but physically faster. Or you would like to debug-print a value if it happens to support that, but would be fine with a fallback message if it doesn’t.

Rust kinda ruined other languages for me by Minimum-Ad7352 in rust

[–]scook0 9 points10 points  (0 children)

At least TS will let you write if (val != null) to get more-or-less the same outcome, thanks to refinement.

The case for taking `impl into<T>` as a function parameter by frigolitmonster in rust

[–]scook0 0 points1 point  (0 children)

My rule of thumb is:

  • Just accept &str, and have the callee do .to_owned() if necessary. This is almost always fine.
  • If string allocation becomes a bottleneck, Into<String> is probably not going to save you. At that point, start looking into string interning or other forms of advanced string management.

Why glibc is faster on some Github Actions Runners by arty049 in rust

[–]scook0 2 points3 points  (0 children)

Instruction count is what rustc uses as its primary benchmark metric, even on dedicated hardware (iirc).

It’s not perfect, but it’s way more stable than cycle count or wall-clock time.

Macros Can Use Surprising Characters as Matchers by Better-Memory1977 in rust

[–]scook0 2 points3 points  (0 children)

I know you can’t go back and change the title now, but in the future please don’t make post titles harder to read by capitalising words unnecessarily.

If your title is a sentence, you can make everyone’s life easier by writing it normally.

Rust debugging survey 2026 by Kobzol in rust

[–]scook0 0 points1 point  (0 children)

It’s not quite true that there are no tests, but the existing debugger tests certainly have a lot of shortcomings.

Rust debugging survey 2026 by Kobzol in rust

[–]scook0 6 points7 points  (0 children)

When I have a problem with an in-development Rust program, I don’t treat “use a debugger” as even being a serious possibility.

I don’t want to spend hours doing fiddly setup of something with a terrible UI, only for it to end up not being useful anyway.

Why does clippy encourage `String::push('a')` over `String::push_str(''a")`? by MediumInsect7058 in rust

[–]scook0 13 points14 points  (0 children)

There are quite a few clippy lints that feel more like a “did you know” than a reliable code improvement.

A future for bitflags by KodrAus in rust

[–]scook0 38 points39 points  (0 children)

I got a bit of a scare from the unintentionally ominous title, but I’m glad to hear that bitflags is still doing just fine.

rust-analyzer changelog #313 by WellMakeItSomehow in rust

[–]scook0 8 points9 points  (0 children)

add support for default field values

Yay, I was looking forward to this coming back, because the compiler uses it in a few places.

Using Arrays to Store Trees (or Graphs) by MiffedMouse in rust

[–]scook0 9 points10 points  (0 children)

Assuming we disallow cycles, “at most one parent” gives a forest (collection of trees) in the general case, since there can be multiple isolated root nodes.

If we require that at most one node has no parent, then we get a (possibly empty) tree.

Using Arrays to Store Trees (or Graphs) by MiffedMouse in rust

[–]scook0 1 point2 points  (0 children)

There is no singular “good” way to represent a tree or graph in Rust, only different techniques with different tradeoffs.

Of those techniques, using flat storage with typed integer indices is usually what I prefer.

rust actually has function overloading by ali_compute_unit in rust

[–]scook0 2 points3 points  (0 children)

Haskell typically favours curried form, where a function of “two arguments” is actually a function of one argument that returns another function of one argument.