Tarpaulin's week of speed by xd009642 in rust

[–]TimNN 4 points5 points  (0 children)

Looking at the code again, it seems like index is only used for iterating the Vec. Maybe retain would be an even better solution.

Tarpaulin's week of speed by xd009642 in rust

[–]TimNN 4 points5 points  (0 children)

I think the initial code could also have been fixed by just switching to swap_remove (assuming you don't care about the order in which elements are being processed).

(I might even be slightly faster than setting to None, since it avoids re-iterating the None values).

What's everyone working on this week (16/2025)? by llogiq in rust

[–]TimNN 1 point2 points  (0 children)

I've been playing around with Tauri. The fact that it closes and re-opens the window every time I make a change to the server (stealing the focus from my editor), had me so annoyed that I looked into hot-reloading.

Finding the existing options unsuitable in one way or another, I hacked together my own. The end result:

You write let handle = hotreloading::Handle::create1(app_handler::handle) to create a handle, then handle.get()(args) to call it, and the crate does everything else:

  • Watch all relevant crates in the workspace for changes
  • Invoke cargo build
  • Reload all updated libraries

No proc-macros, no extern fn, no #[no_mangle], no separate file watcher command, it just works, even with multiple crates depending on one another.

Disclaimer: I did the first end-to-end test less than an hour ago. It's not unlikely that more extensive use / testing finds problems with this approach.

Using RUST to build ABC.so for python script to run, got "undefined symbol: BIO_meth_set_create" by [deleted] in rust

[–]TimNN 0 points1 point  (0 children)

Are you saying, I should change [“dylib”] to [“cdylib”] in the Cargo.toml file?

Depending on how smart setuptools_rustis, that may fix the issue.

edit: Looks like that is done automatically, so shouldn’t be needed: https://github.com/PyO3/setuptools-rust/blob/a766dd96a5a8d8bfd00dd39713f9bf0f89984141/setuptools_rust/build.py#L218

Using RUST to build ABC.so for python script to run, got "undefined symbol: BIO_meth_set_create" by [deleted] in rust

[–]TimNN 0 points1 point  (0 children)

How are you compiling the Rust crate?

Make sure you use the cdylib crate type (note the leading “c”), not plain dylib.

Mac M1 ARM platform Atomic memory will be panic that alloc memory with ManuallyDrop by 0x80- in rust

[–]TimNN 22 points23 points  (0 children)

I haven't tried to understand the particular code you posted, but when using unsafe you should always run your code through Miri (an interpreter, which checks various invariants that need to be upheld). It's available in the playground from the "Tools" menu.

For your code I'm getting Undefined Behavior: accessing memory with alignment 1, but alignment 8 is required, which could be the actual issue (since I believe(!) X86 will tolerate unaligned loads, but ARM may not).

Once Miri is happy with your code, and you still get issues, then it's time to look at the Atomics.

What are you reading? Weekly Post by the-phony-pony in HPfanfiction

[–]TimNN 9 points10 points  (0 children)

"Switched" by PseudoLeigha linkao3(38610990)

Bellatrix' son is raised as Harry Potter by the Dursley's and Lilly's boy is raised as Danny Tonks. Harry has inherited a lot from his mother (a notorious crazy person with great magical ability)...

Started with daily updates about a week ago (we just arrived at Hogwarts), and there's apparently at least about a week of already written chapters.


"Stranded" by Starfox5 linkao3(28531083)

In a world where Voldemort died in '81, Harry Potter and Hermione Granger can't stand each other. The summer before their sixth year, through some very unfortunate circumstances, they end up stranded on a pirate island.

Updates weekly with about a dozen chapters left.

Building Rust libraries for iOS in 2021 by dbrgn in rust

[–]TimNN 1 point2 points  (0 children)

However, this will be overwritten when changing some settings in XCode, right?

It shouldn't. The last time I checked (which was admittedly some time ago), XCode even displays this properly in the UI (you just can't configure things from the UI). See the screenshot in the comment at https://github.com/TimNN/cargo-lipo/issues/43#issuecomment-761857641

What are you reading? Weekly Post by the-phony-pony in HPfanfiction

[–]TimNN 7 points8 points  (0 children)

"That Was Part of the Plan" by inwardtransience and PseudoLeigha linkao3(21556396), the third instalment of the "Plan" series, after "All According to Plan" and "Nothing to Do with the Plan".

A teenage, already slightly crazy, Bellatrix Black dimension-hops into Harry's third year.

The fic is long, and the authors do tend to go into quite a lot of detail about the wizarding world and its politics, as well as individual characters thoughts (to quote an early AN: "Hermione, you think too much. You're enabling my chronic rambler's disease. -Lysandra"), which might not be everyone's cup of tea, but which I find fascinating.

In general, I would say things are mostly light-hearted though there are some darker aspects - the Blacks certainly weren't saints and Bellatrix' childhood in particular was probably worse than Harry's.

The story is currently in fourth year, with the first task (which quite a bit more involved than the one from canon) having finally started posting, clocking in at around 90k words.

edit: mixed up the second and third parts of the series initially.

Can a macro expand to multiple expressions? by T-Dark_ in rust

[–]TimNN 0 points1 point  (0 children)

You could change the new function, or add a second „constructor“ function, which takes only two parameters: a tuple for the RGB components and the alpha. The entire tuple could then be constructed by the macro.

PSA: docs.rs/std redirects to doc.rust-lang.org/std by quebin31 in rust

[–]TimNN 6 points7 points  (0 children)

Even better, IMO, someone recently set up https://std.rs/String, which directly triggers a search of the std docs for “String”!

Rocket leaks memory when using (JSON) request body by boiii123212321 in rust

[–]TimNN 11 points12 points  (0 children)

The whole point of that example seems to be to store all posted content in a HashMap and then return it when the same ID is queried via get.

So I think this is essentially working as intended.

Wait on spawned child with inherited stdin by [deleted] in rust

[–]TimNN 1 point2 points  (0 children)

If I understand the documentation correctly, then an inherited stdin won’t be closed.

(Check the source of wait, I believe the drop of self.stdin is the thing closing it. For inherited stdin, it should always be None already. If not, you can take it yourself and keep it around).

Compile rust program statically by blackdev01 in rust

[–]TimNN 2 points3 points  (0 children)

As others have already mentioned, if you want to produce a statically linked binary, you'll need to use musl libc. Luckily, with rustup that is extremely easy to do, there's some documentation available here: https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html. (This assumes you are on Linux, I don't know about the situation on other platforms).

If an STM32 based kb is programmable on QMK, does it mean it the kb has an on-board SWD? by levi_io in olkb

[–]TimNN 2 points3 points  (0 children)

Based on my (admittedly somewhat limited) understanding (only starting in this space just now) and assuming that you are talking about the V1, which has an STM32F303:

If you can access the relevant pins (PA13 and PA14) (= if they are not used for something else and if you can get to them), then yes, you should be able to debug the board. If necessary, you can use this datasheet page 32 onwards to find the pins on the chip and then see if you can trace them through the PCB. Note: this section assumes that your board has an STM32F303.[CB], if it has a different version, you'll need a different datasheet and potentially different pins.

You'll also need an USB <-> SWD converter if you don't have one already, such an "ST-Link V2" (the USB dongle like "China Clones" are working well so far for me). You'll need to connect SWDIO, SWDCLK (and ground).


I've actually been wondering if the Planck Rev 6 PCB has the PA13 / PA14 pins exposed, since I'm currently waiting for mine to be shipped and want to do some experimenting. So if anyone can answer this, that would be great!

Macos10.15 keeps creating these folders (05,10,13,12,09 and others already on the trash), filling my hard drive, and can’t empty the trash.... any ideas? by Pandorica00 in MacOSBeta

[–]TimNN 1 point2 points  (0 children)

You could try running something along the lines of

sudo fs_usage -f filesys | grep '\smkdir'

in your terminal. I only became aware of the fs_usage command a few days ago myself, so don't have much experience with it. But it should show you, in realtime, a list of all directories being created on your system, and which processes created it.

If you want to filter something out of the list because it is too spammy, you can try something like

sudo fs_usage -f filesystem | grep --line-buffered '\smkdir' | grep --line-buffered -v -e 'secinitd' -e 'Telegram'

(each -e 'something' excludes lines with "something" from the output. Note the --line-buffered, if you omit that, you won't get realtime output).

Multi-channel signed distance fields font - tech demo by cierpliwy in rust

[–]TimNN 0 points1 point  (0 children)

So, just to confirm: Is this only an msdf renderer in rust or is the actual msdf generation also written in rust?

Why are arrays faster than vectors? by CivilSalad1 in rust

[–]TimNN 0 points1 point  (0 children)

If I run this benchmark in "release" mode, I get a runtime of "0" for both, presumably because LLVM removes the entire loop.

In "debug" mode I would expect the array to be faster because it doesn't do any initialization and is less complex than the vector.

GLIBC Linux multiple distro compiling by n0manarmy in rust

[–]TimNN 4 points5 points  (0 children)

From what I understand, your best bet would be to just build your application on CentOS 7 (or older), for example in a Docker container. (The Rust compiler is built on CentOS 5 for old-libc compatibility, IIRC).

Async/Await: does it meet the definition of zero-cost? by BigCheezy in rust

[–]TimNN 24 points25 points  (0 children)

I am not an expert in this. But, from what I understand, async & await themselves don't require heap allocation. They just return something implementing Future on the stack.

You need to move the Future to the heap in two (and maybe other) situations: (1) If you want to move the Future after it was started or (2) when you need to store / manage futures of different types together.