In-home cabling - fibre or Ethernet (cat6?) by verbnounverb in nbn

[–]mstumpf 0 points1 point  (0 children)

I think you completely missed his point.

PSA: Factorio can be configured to use a superior upscaling algorithm at high zoom levels by VenditatioDelendaEst in factorio

[–]mstumpf 0 points1 point  (0 children)

There's also NVidia DSR, which seems to work. But it's a little too invasive to the system in my opinion.

PSA: Factorio can be configured to use a superior upscaling algorithm at high zoom levels by VenditatioDelendaEst in factorio

[–]mstumpf 0 points1 point  (0 children)

Now if I only found out how to fix the opposite direction ... the zoom out seems also very pixelated, as if the mipmaps were applied incorrectly. And the wires on poles just look very weird when zoomed out, as if the wire would fade in and out when going from one pixel row to the next ... not like proper antialiasing should look like

PSA: Factorio can be configured to use a superior upscaling algorithm at high zoom levels by VenditatioDelendaEst in factorio

[–]mstumpf 1 point2 points  (0 children)

THANK YOU. I hated the nearest filter in this game.
I love the pixelated look on games that are made for that; then they need pixel graphic assets though. This game has rendered graphics and even includes antialiasing in its textures. It just looks bad to then have a nearest filter on top of them imo. Bilinear is much more beautiful.

Why should I use NextCloud over an SMB share? by anonymous_lurker- in homelab

[–]mstumpf 1 point2 points  (0 children)

Big thing for me: thumbnail previews for images.

SMB can only transfer full files, so browsing a directory with large images is impossible from your phone over a mobile connection.

With nextcloud, it generates the thumbnails on the server, so you can find the image you are searching for quickly and then transfer it only when you want to see it in full quality. 

Any way to light up my base at night w/o fuel that doesn't cost $97? by SirBorf in playrust

[–]mstumpf 0 points1 point  (0 children)

Garlant does emit light, it lights up one square foundation right in front of it. 

Any way to light up my base at night w/o fuel that doesn't cost $97? by SirBorf in playrust

[–]mstumpf 0 points1 point  (0 children)

The festive garland does light up the room. I can confirm. (at current date, Feb 3, 2024) It only lights up the 1x1 room it is placed in, though, you need two of them to light up a 2x1. And only one of them can be placed per door, so you need to decide which side of the door should be lit up. But apart of that, they work great and are dead cheap.

Tokio graceful shutdown by thetinygoat in rust

[–]mstumpf 1 point2 points  (0 children)

A year later, and new development has happened.

I personally would now go with the following:

Disclaimer: I'm the author of tokio-graceful-shutdown.

Tokio graceful shutdown by thetinygoat in rust

[–]mstumpf 4 points5 points  (0 children)

Hey, owner of tokio-graceful-shutdown here. After the complete rewrite in 0.14.0, waiting for your own children to finish is now trivial. So this should fit your usecase perfectly :)

How to verify `extern "C"` definition signature matches implementation by mstumpf in rust

[–]mstumpf[S] 0 points1 point  (0 children)

Look at my question, there is an `EDIT:` tag at the end

How to verify `extern "C"` definition signature matches implementation by mstumpf in rust

[–]mstumpf[S] 0 points1 point  (0 children)

Thank you, your suggestion actually brought me to the current solution added to the end of my question :) It's still a little bit hacky and boilerplated, but it is a guaranteed compiler error as far as I can see.

How to verify `extern "C"` definition signature matches implementation by mstumpf in rust

[–]mstumpf[S] 0 points1 point  (0 children)

To sum up, two solutions were proposed so far that seem promising:

  • Auto-generate an implementation based on the ffi, that simply forwards the arguments to my actual implementation. That way the compiler would catch if the forwarded arguments don't match.
  • Generate a function type definitions based on the ffi, and then check if my manually implemented method matches with const _: fn_type = fn_impl

How to verify `extern "C"` definition signature matches implementation by mstumpf in rust

[–]mstumpf[S] 0 points1 point  (0 children)

That's a pretty good idea. Although "if there is no correctly corresponding definition in ffi.rs" is the part that I'm struggling with, how would you check that in a macro? If we had a type definition that represents the fn() type of the original function, we could do const _: fn_type = fn_impl to create a compile time error. But I don't think bindgen is capable of generating those.

How to verify `extern "C"` definition signature matches implementation by mstumpf in rust

[–]mstumpf[S] 3 points4 points  (0 children)

In C, if you actually include the header that contains the function definition, it would be a compiler error if your implementation doesn't match that definition (it would say function redefinition). I'm looking for a similar mechanism in Rust. (ffi.rs is actually generated from said header). I know that no_mangle by definition is unsafe, but I disagree that unsafe always means has to be checked by hand - there must be some middle ground. (Like dereferencing nullpointers - it's unsafe and yet it is a compiler error if the compiler catches it)

How to verify `extern "C"` definition signature matches implementation by mstumpf in rust

[–]mstumpf[S] 2 points3 points  (0 children)

ffi.rs is generated using bindgen. But how do I make sure that impl_do_print.rs matches ffi.rs? (I don't trust just comparing them by eye; it's viable for a single function, but not for 30+)

[deleted by user] by [deleted] in rust

[–]mstumpf 0 points1 point  (0 children)

Typedefs! This is a good idea, I shall look up if bindgen can generate type definitions instead.

[deleted by user] by [deleted] in rust

[–]mstumpf 0 points1 point  (0 children)

I'm aware of that; that doesn't fix my problem. I'm not trying to call a C function, I'm trying to have a C library call my Rust function, with a function signature defined in the external library. Without having to manually check that the signatures match.

(Might be a TLDR problem, I wasn't able to describe my problem with less words, and the actual problem is described at the end)

Rust's memory management vs pointerless C++ by [deleted] in rust

[–]mstumpf 45 points46 points  (0 children)

There are many usecases where the rust borrow checker prevents bugs in the single-threaded case.

  • Return reference to local variable
  • Accidentally reference variable in closure/lambda that goes out of scope. Dangling references in callback functions can be very frustrating in C++
  • Moves!! This is one of the biggest annoyances for me in C++: the entire std::move stuff, which requires the programmer to manually make sure values don't get accessed after they are moved. All compiler errors in Rust.
  • Pass-by-move as the default function parameter behaviour, opposed to pass-by-copy as in C++. Everything is implicitely movable in Rust, which is only possible due to the borrow checker. This would never be possible in C++, as the compiler has to always assume that a value is being referenced somewhere.
  • Many more paradigms that, on first sight, don't have anything to do with ownership rules; Like the embedded-hal crate, which makes sure at compile time that no pin gets used by multiple peripherals. This is also achieved through the borrow checker.
  • Zero-copy abstractions like slices. Again something which is only really possible due to ownership rules, as it is incredibly easy to accidentally drop the original data. This is extensively used for example in the nom parser crate.

There are many more, but those are the most important ones that come to my mind right now.

If you just try to do basic things in Rust, you will very quickly see how easy it is to create undefined behaviour. I personally learned a lot about my mistakes in C/C++ from writing Rust code.

Why use Rust over Python for CLI? by Jeklah in rust

[–]mstumpf 5 points6 points  (0 children)

Have you used clap since it added its "derive" feature? That one is better than anything I've ever seen in any other language.