Rust

typst.app

>Typst is a new markup-based typesetting system that is designed to be as powerful as LaTeX while being much easier to learn and use Typst is awesome, in particular if you want to generate documents programmatically.

40
7

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

10
2

It's possible that the .io cctld is going to go away [0]. Does crates.io have a backup plan at all? Does anyone know what problems it would end up causing? I imagine the package registry having to move domains is going to cause a ton of problems. Frankly, it's concerning to me that so much of the Rust ecosystem has chosen to standardize on shaky ccTLDs. The Indian Ocean Territory (.io) is a small island territory whose only inhabitants are a single military base, it is crazy to use that domain for something important. Serbia (.rs) is more stable, but they could still cut off access for non-Serbians if they wanted to. [0] - https://en.wikipedia.org/wiki/.io#Phasing_Out

47
28

If we were to create a Rust version of [this page for Haskell](https://wiki.haskell.org/Blow_your_mind), what cool programming techniques would you add to it?

65
46
github.com

Links: - [https://atproto.com](https://atproto.com/) - [https://atproto.com/articles/atproto-for-distsys-engineers](https://atproto.com/articles/atproto-for-distsys-engineers) - [https://www.blackskyweb.xyz](https://www.blackskyweb.xyz/) - [https://bsky.app/profile/rudyfraser.com/post/3l6d7mmzhik2r](https://bsky.app/profile/rudyfraser.com/post/3l6d7mmzhik2r) > For a lot of us, atproto projects are some of the biggest (most users, most publicized, most code written, etc.) projects we’ve ever done. For me, it’s also my first time working in open source (ironically, someone asked me to be more open about that) > > If you can help, pls check out open issues. I know not everyone thinks highly of atproto around these parts, but please don’t let that get in the way of welcoming a fellow rustacean into the open source world 🦀

32
12
rust
Rust Deebster 1w ago 100%
Bacon v3 released
https://dystroy.org/bacon/

Bacon is a Rust code checker designed for minimal interaction, allowing users to run it alongside their editor to receive real-time notifications about warnings, errors, or test failures (I like having it show clippy's hints). It prioritizes displaying errors before warnings, making it easier to identify critical issues without excessive scrolling. Screenshot (from an old version I think): ![](https://lemm.ee/api/v3/image_proxy?url=https%3A%2F%2Fdystroy.org%2Fbacon%2Fimg%2Ftest.png) v3 adds support for [cargo-nextest](https://nexte.st/), plus some QoL improvements. [v3.0.0 release notes](https://github.com/Canop/bacon/releases/tag/v3.0.0)

30
4

I'm making this post after endless frustrations with learning Rust and am about to just go back to TypeScript. Looking at Rust from the outside, you'd think it was the greatest thing ever created. Everyone loves this language to a point of being a literal cult and its popularity is skyrocketing. It's the most loved language on Stackoverflow for years on end. Yet I can't stand working in it, it gets in my way all the time for pointless reasons mostly due to bad ergonomics of the language. Below are most of the issues I've encountered: - Cargo is doing too many things at once. It's a build system but also a package manager but also manages dependencies? Idk what to even call it. - Syntax is very confusing for no reason. You can't just look at rust code and immediately know what it does. Having to pollute your code &, ? and .clone() everywhere to deal with ownership, using :: to refer to static methods instead of a "static" keyword. Rust syntax is badly designed compared to most other languages I used. In a massive codebase with tons of functions and moving parts this is unreadable. Let's take a look at hashmaps vs json ```rust let mut scores = HashMap::new(); scores.insert(String::from("Name"), Joe); scores.insert(String::from("Age"), 23); ``` Supposively bad typescript ```javascript const person = { name: "joe", age: 23 } ``` Js is way more readable. You can just look at it and immediately know what the code is doing even if you've never coded before. That's good design, so why do people love rust and dislike typescript then? - Similarly, Async code starts to look really ugly and overengineered in rust. - Multiple string types like &str, String, str, instead of just one "str" function - i32 i64 i8 f8 f16 f32 instead of a single unified "number" type like in typescript. Even in C you can just write "int" and be done with it so it's not really a "low level" issue. - Having to use #[tokio:main] to make the main function async (which should just be inbuilt functionality, btw tokio adds insane bloat to your program) yet you literally can't write code without it. Also what's the point of making the main function async other than 3rd party libraries requiring it? - Speaking of bloat, a basic get request in a low level language shouldn't be 32mb, it's around 16kb with C and libcurl, despite the C program being more lines of code. Why is it so bloated? This makes using rust for serious embedded systems unfeasible and C a much better option. - With cargo you literally have to compile everything instead of them shipping proper binaries. Why??? This is just a way to fry your cpu and makes larger libraries impossible to write. It should be on the part of the maintainer to build the package beforehand and add the binary. Note that i don't mean dependencies, I mean scripts with cargo install. There is no reason a script shouldn't be compiled beforehand. Another major issue I've encountered is libraries in Rust, or lack thereof. Every single library in rust is half-baked. Axum doesn't even have a home page and its docs are literally a readme file in cargo, how's that gonna compare to express or dotnet with serious industry backing? If you write an entire codebase in Axum and then the 1 dev maintaining it decides to quit due to no funding then what do you do? No GUI framework is as stable as something like Qt or GTK, literally every rust project has like 1 dev maintaining it in his free time and has "expect breaking changes" in the readme. Nothing is stable or enterprise ready with a serious team with money backing it. As for "memory safety", it's a buzzword. Just use a garbage collector. They're invulnerable to memory issues unless you write infinite while loop and suitable for 99% of applications. "But muh performance, garbage collectors are slow!" Then use C or C++ if you really need performance. Both of them are way better designed than Rust. In most cases though it's just bikeshedding. We're not in 1997 where we have 10mb of ram to work with, 9/10 times you don't need to put yourself through hell to save a few megabyes of a bundle size of a web app. There are apps with billions of users that run fine on php. Also, any program you write should be extensively tested before release, so you'd catch those memory errors if you aren't being lazy and shipping broken software to the public. So literally, what is the point of Rust? From the outside looking in, Rust is the most overwhelming proof possible to me that programmers are inheritly hobbists who like tinkering rather than actually making real world apps that solve problems. Because it's a hard language, it's complicated and it's got one frivelous thing it can market "memory safety!", and if you master it you're better than everyone else because you learned something hard, and that's enough for the entire programming space to rank it year after year the greatest language while rewriting minimal c programs in rust quadrupling the memory usage of them. And the thing is, that's fine, the issue I have is people lying and saying Rust is a drop in replacement for js and is the single greatest language ever created, like come on it's not. Its syntax and poor 3rd party library support prove that better than I ever can "Oh but in rust you learn more about computers/low level concepts, you're just not good at coding" Who cares? Coding is a tool to get shit done and I think devs forget this way too often, like if one works easier than the other why does learning lower level stuff matter? It's useless knowledge unless you specifically go into a field where you need lower level coding. Typescript is easy, rust is not. Typescript is therefore better at making things quick, the resourse usage doesn't matter to 99% of people and the apps look good and function good. So at this point I'm seeing very little reason to continue. I shouldn't have to fight a programming language, mostly for issues that are caused by lack of financial backing in 3rd party libraries or badly designed syntax and I'm about to just give up and move on, but I'm in the minority here. Apparently everyone loves dealing with hours and hours of debugging basic problems because it makes you a better programmer, or there's some information I'm just missing. Imo tho think rust devs need to understand there's serious value in actually making things with code, the ergonomics/good clean design of the language, and having serious 3rd party support/widespread usage of libraries. When you're running a company you don't have time to mess around with syntax quirks, you need thinks done, stable and out the door and I just don't see that happening with Rust. If anyone makes a serious comment/counterargument to any of my claims here I will respond to it.

-45
98
github.com

This is my first ever Rust program. The motivation of this is to create a soundboard with global hotkey support on Wayland, because Soundux wouldn't add it :< That's why this soundboard is structurally very similar to Soundux. Here's a screenshot: ![](https://lemm.ee/api/v3/image_proxy?url=https%3A%2F%2Flemmy.world%2Fpictrs%2Fimage%2F75f1df15-f9f1-4a2a-9d01-ebd5f68e8a02.png)

18
5

Just started learning Rust today and got Rust installed, got the hello world example compiled and running. I installed `rust-analyzer` and `CodeLLDB` extensions in VSCode. Enable the `debug.allowBreakpointsEverywhere` settings to VSCode to be true. Setup a debug configuration in VSCode. However I keep getting errors from `rust-analyzer` when I run the debugger... ``` 2024-10-06T22:16:04.808655Z ERROR FetchWorkspaceError: rust-analyzer failed to load workspace: Failed to load the project at /home/john/Documents/Snippets/Rust/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /home/john/Documents/Snippets/Rust/Cargo.toml, Some(Version { major: 1, minor: 81, patch: 0 }): Failed to run `cd "/home/john/Documents/Snippets/Rust" && RUSTUP_TOOLCHAIN="/home/john/.rustup/toolchains/stable-x86_64-unknown-linux-gnu" "/home/john/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/john/Documents/Snippets/Rust/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"`: `cargo metadata` exited with an error: error: failed to parse manifest at `/home/john/Documents/Snippets/Rust/Cargo.toml` Caused by: no targets specified in the manifest either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present ``` I not sure how to fix this. I would like to get the VSCode debugger to work for launch debugging, attach debugging and launch and attach debugging for rust running inside a docker container. This will be a good setup for getting started I believe. This is my VSCode debugger configuration... ``` { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Debug", "program": "${workspaceFolder}/hello-world", "args": [], "cwd": "${workspaceFolder}" } ] } ``` Any help and advice will be most appreciated.

12
4

I was using [Iced](iced.rs) as a dependency, but wanted to tweak its source code for some reason, so I jumped into the folder where cargo downloads dependencies, and went into iced_wgpu 13.5 (I think that's the version). I could make a change, then run `cargo clean -p iced_wgpu && cargo check` in my other project for instant feedback, yet it took rust_analyzer *at least* 5 whole minutes to stop hallucinating. Can I disable some functionality of `rust_analyzer`? I only use it for jump-to-definition, linting and syntax highlighting; I don't even use autocomplete. # Setup: * Desktop that thermally throttles only when both the IGPU and the CPU are under full load, and is cool otherwise. * CPU: Intel I5-7500 * RAM: 8 GiB DDR-4 * Editor: NVIM v0.11.0-dev | Build type: RelWithDebInfo | LuaJIT 2.1.0-beta3 (I had the same issue with other versions as well). # TLDR What can I disable in rust_analyzer to boost performance while maintaining jump-to-definition, linting and syntax-highlighting, or what can I do to boost rust_analyzer for big projects in general?

13
6

I really like the idea of a package/dependency manager. It just seems that when ever I am reading a tutorial and they want to import something that is not standard they say write this in to your TOMOL not cargo install it. Like when reading python docs they all say to use pip or something. Sorry it just seems that Cargo is somewhat overlooked or is it just my perception?

12
10
rust
Rust gulia 3w ago 33%
C++ VS Rust

C++ VS Rust [https://brevzin.github.io/c++/2024/09/30/annotations/](https://brevzin.github.io/c++/2024/09/30/annotations/) [@cppguide](https://mastodon.social/@cppguide) [@rust](https://programming.dev/c/rust)

-1
0
https://brevzin.github.io/c++/2024/09/30/annotations/

This is a blog post that really is about C++, but with a look at how Rust does things. So, this is an interesting C++/Rust comparison for once.

27
3
github.com

Last week I basically duplicated the serialization code to provide better debug output.... today, I see this pass in my Mastodon feed. 😀 Well... what are the odds... most likely close to 100% according to how the universe seems to operate.

26
4
kellnr.io

Kellnr, the crate registry for Rust got an update. The latest version contains bug fixes and dependency updates. If you are interested in hosting private crates that must not be on crates.io, check it out.

16
0

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

24
13
https://sabrinajewson.org/blog/truly-hygienic-let

A short post on how variable names can leak out of macros if there is a name collision with a constant. I thought this was a delightful read!

53
8

Hi. I've been learning Rust for a while, and I want to take on an actual project now to learn even more. I need to be pointed in the right direction for one aspect of the affair, and I hope someone here can help me. I want to create a deck tracker for Hearthstone that runs natively in Linux. This is, on the back end, a fairly simple matter of parsing a constantly updated file that tracks everything that happens in the game. On the front end, however, I want to create a window that sits on top of the fullscreen Hearthstone window and shows me stuff. The "stuff" doesn't have to be images or anything fancy, I'll take whatever I can get, but I don't know how to get started on this part. So the task is as follows: Create an overlay on top of the fullscreen Hearthstone client, preferably under Wayland, and update it constantly with new information about cards drawn, cards left in deck, that sort of thing. How do I tackle this problem? Are there any crates that'll let me create such a window and render stuff to it? How would *you* approach the problem? Thanks in advance.

29
10
github.com

I've always been curious about this. If I were to take a snapshot of a git repo at a particular point in time, who would be the top contributors by active lines of code? And then, what type of files have they contributed the most? So I built this little tool. I've been wanting to learn rust for quite some time now and this was one of my first projects in it. It was a lot of fun! It uses `git` under the hood to obtain the information and it's nothing fancy, but keen to hear what you think.

20
1

[\#rust](https://mathstodon.xyz/tags/rust) analyzer question for [#emacs](https://mathstodon.xyz/tags/emacs) folks In client more I see run and debug But gui emacs I don't .. why pfa [@rust](https://programming.dev/c/rust)

9
1

Hi all. I want to develop a plugin system within my program, and I have a trait that functions defined by plugins should implement. Currently, my code gets all the functions in a HashMap and then calls them by their name. Problem is, I have to create that hashmap myself by inserting every function myself. I would really appreciate it if there was a way to say, suppose, all pub members of `mod functions::` that implement this `trait PluginFunction` call `register(hashmap)` function. So as I add more functions as `mod` in `functions` it'll be automatically added on compile. Pseudocode: Files: ``` src/ ├── attrs.rs ├── functions │   ├── attrs.rs │   ├── export.rs │   └── render.rs ├── functions.rs ├── lib.rs ``` Basically, in `mod functions` I want: ``` impl AllFunctions{ pub fn new() -> Self { let mut functions_map = HashMap::new();[[ register_all!(crate::functions::* implementing PluginFunction, &mut functions_map); Self { function_map } } } ``` Right now I'm doing: ``` impl AllFunctions{ pub fn new() -> Self { let mut functions_map = HashMap::new();[[ crate::functions::attrs::PrintAttr{}.register(&mut functions_map); crate::functions::export::ExportCSV{}.register(&mut functions_map); crate::functions::render::RenderText{}.register(&mut functions_map); // More as I add more functions Self { function_map } } } ```

19
10

Hey all, just sharing a small, single-page site I built using Leptos + TailwindCSS, mainly intended as a demo for an API I built using Axum. Hope someone also finds it interesting! I'm sharing this site and not the API itself cause I figure it's easier to look at and understand, but if you want to roast some code I would appreciate any feedback you have on the API itself (repo [here](https://github.com/Rolv-Apneseth/world-wonders-api)). Trying to leave the front end developer scene so this is the first API I've tried building, fairly basic but it was fun (I am a big Civ V fan - I hear it's inspired by some niche thing called human history?). Edit: whoops, looks like the link didn't get set cause I put an image - the site is available [here](https://explorer.world-wonders-api.org), and the repo for it is [here](https://github.com/Rolv-Apneseth/world-wonders-explorer). The live API is available [here](https://www.world-wonders-api.org/v0/docs#model/apikeylocation)

17
2