[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: rust_logo.png (80 KB, 480x480)
80 KB
80 KB PNG
/rust/ - Dedicated to the discussion of anything Rust related.
Rust is a programming language designed to ensure memory and concurrency safety while attempting to be as fast as language like C and C++.

## News ##
A Re-Implementation Of The EROFS File-System In Rust Has Started - https://www.phoronix.com/news/EROFS-Rust-Code-Starts
Military researchers ask industry for ways of translating legacy software automatically from C to Rust - https://www.militaryaerospace.com/trusted-computing/article/55138748/software-c-to-rust-translating
"Prossimo" has worked with a consultancy group called Immunant to convert the AV1 video decoder 'dav1d' to Rust. https://www.memorysafety.org/blog/porting-c-to-rust-for-av1/
Google says replacing C/C++ in firmware with Rust is easy - https://www.theregister.com/2024/09/06/google_rust_c_code_language/
Changes to `impl Trait` in Rust 2024 - https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules.html
Announcing Rust 1.81.0 - https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html
Programs of the 9th edition of RustConf announced! - https://rustconf.com/programs/

## Learn Rust! ##
The Rust Book - https://doc.rust-lang.org/book/
The Rust Book (Abridged) - https://jasonwalton.ca/rust-book-abridged/
Collection of guides and tutorials - https://pastebin.com/rUiqjPgL

Conversation starters:
>What are you currently working on?
>Are you learning anything specific? How is it going?
>Got questions about Rust? Ask them!

Previous thread: >>102381718
>>
>>102429653
is rust good for malware?
>>
>>102429787
since rust has only one compiler all rust software are potentially malware
>>
>>102429787
Yes, Rust is an amazing target for spreading malware to devs via supply chain attacks. These retards write programs that have like 700 transitive dependencies and call that good design. You just need to find one microlibrary where you can insert your malware.
>>
>>102429787
Yes, Rust is more powerful than C++, C, and Go for malware.
>>
>>102429787
rust is a shemaleware
>>
>>102430967
that's unfortunately true
there have been multiple name squatting libraries in the past
>>
>>102430967
>write python script to pull full cargo dependency data
>find the packages that have the most reverse dependencies
>filter down to packages with few lines of code and few github contributors to find the microlibraries
>look at pull request acceptance delays to find packages that seem to auto-accept them
>look at readmes to find packages looking for a new maintainer
>check very old github accounts for e-mails to see if they can be compromised via an old e-mail that is no longer registered but still associated with the account
>check common passwords against github accounts of people who appear retarded
>check for projects that could be deleted soon, maybe you can take their name
>wait until you've collected 3-10 projects
>insert malware into all of them at once
>boom, now you own the computer of every rust dev
>exfiltrate data while mining monero
I'm surprised that nobody has done this yet.
>>
File: 0_bB31wcohp7pePk9C.jpg (197 KB, 1200x1200)
197 KB
197 KB JPG
What language is the closest to "Rust, but garbage collected"?
>>
>>102432789
Probably because the task of finding a small dependency that is used by a lot of major crates while also tied to an account with an password that can be brute-forced and getting around GitHub's mandatory 2FA and the email's 2FA is an infeasible task.
Let alone doing that for 3-10 projects and pushing updates all at once without getting detected instantly.
You would be better off making a new project that gets popular or gaining trust over years till you have access to permissions and then publishing malware, like that one Linux dev in the xz utils.
But why waste time doing something destructive?
>>
>>102433501
OCaml probably
>>
>>102433553
I forgot that GitHub has made 2FA mandatory for old accounts too in 2024. My bad. So maybe it's not that easy after all.
>without getting detected instantly
I think that if the libraries were pretty obscure, with not many contributors and mostly used transitively, then it could go undetected for quite a while?
>But why waste time doing something destructive?
Idk, I'm not gonna do what I described of course. There are plenty of people on the Internet who want to mine crypto or just troll though. Hence my surprise that it hasn't happened yet.
>>
>>102433660
>I think that if the libraries were pretty obscure, with not many contributors and mostly used transitively, then it could go undetected for quite a while?
But that kinda defeats the idea of attacking many people at once, no? The more it is used by downstream dependencies, the more likely it will be detected.
>There are plenty of people on the Internet who want to mine crypto or just troll though.
Easier ways to do that (like making a browser *cough* shill lion *cough* or being transphobic on mongolian basket weaving forums)
Chances of it happening are near zero.
>>
>>102433714
Hopefully you're right! I don't have that much faith in people reviewing their dependencies. The average programmer seems to just slap them into the project without reviewing the code. It doesn't seem unlikely to me that malicious shit would go unnoticed for days or weeks if it was in some obscure library that tends to be an indirect dependency but not a direct one.
>>
>>102429787
i think so, but go was really popular a few years ago and probably still is. i remember seeing a bunch of tools like this in go
https://www.youtube.com/watch?v=3RQb05ITSyk
>>
IT BEGINS
https://sharetext.io/?slug=19909b8d
>>
>>102433501
MoonBit
>>
why does systems language threads like C++/Rust get so little activity? filtered? They always die <100 replies
>>
>>102435671
no one uses them
>>
>>102435671
people who actually write code do not use this board
>>
>>102435068
Kek. The list of demands got me.
>>
>>102435068
the seething is DELICIOUS
>use GNU
>don't use GNOME
heck, even poor Oxide that is basically on its own island in the middle on nowhere was mentioned - you have to buy their hardware, and it costs a bit more than a Thinkpad so /g/ will never touch it. Also, you can run the -arr stack in 1/10th of a single sled, what would they do with the rest?
shit, that alone should merit a fork of Oxide's virtualization stack to regular hardware - I want these guys to cry over the ruins of XCP-ng and PVE
>>
File: 1722465786485180.jpg (67 KB, 800x450)
67 KB
67 KB JPG
>>102438145
>seething
Zommers can't even identity satire anymore when it's slapped in their face.
>>
>>102438201
https://en.wikipedia.org/wiki/Poe%27s_law
so many fascists look at Starship Troopers and think "yes, I'm seen"
>>
>>102430967
Just because you prepend an act with "just" doesn't mean it's easy
>breaking any encryption is easy, just guess the right number
The amount of dependencies has no impact on the ease of supply chain attacks
>>
>>102429653
i wish there was a language like rust but no weird dependency shit with cargo
and normal compile times
id be all over that

i guess i’ll learn rust and not import a single library other than maybe tokio and some winapi stuff i hope
>>
>>102430967
>You just need to find one microlibrary where you can insert your malware.
>automated scanner picks it up
>crate gets yanked immediately
>>
>>102429787
no. The language is capable of creating malwares but its not a good language to develop a malware in. Lets say someone is using Rust and another is using C. The C guy will write the malware, experiment various other ways to perform the exploit by still will have a life outside programming and will leave the Rust dev guy in the dust.
The Rust dev guy will be too busy fighting with the compiler, making sure to write code the compiler way, has no choice but to reformat majority of the code(most of the time) to experiment and write the exploit differently all after making sure that he has at least 20GB free disk space so that he could build his project.
Yes, Rust is capable language for malwares but C, Python and Go will come out as much better tools for the job for a lot of reasons, the primary one being ease to perform quick prototyping.
>>
>>102438595
>The Rust dev guy will be too busy fighting with the compiler, making sure to write code the compiler way, has no choice but to reformat majority of the code(most of the time) to experiment and write the exploit differently all after making sure that he has at least 20GB free disk space so that he could build his project.
These are _literally_ all skill issues.

Rust is becoming increasingly popular among malware authors (see: BlackCat, etc) due to its reliability and how it can often times evade detection.
>>
>>102438636
>These are _literally_ all skill issues.
not having several GB of disk space lying around and a high speed internet and processor to build the project is not a skill issue. Other actual issues will demand several times more time to be invested than C, Python and Go to make up for them and that is not something that should be ignored.

>Rust is becoming increasingly popular among malware authors (see: BlackCat, etc) due to its reliability and how it can often times evade detection.
yes, that's a given as Rust is very well capable of that. But if you are implying that Rust will dominate and take over the entire malware world, I beg to differ. It ain't gonna happen as having to "unsafe()" often would annoy the heck out of anyone in the long term.
>>
>>102435068
>>102438201
want to really blow their minds?
tell them to stop using LetsEncrypt, because ISRG is rewriting many internet underpinnings in Rust and is starting the process of moving LetsEncrypt to rust-tls.
Also tell them to stop using 4chan because Cloudflare's reverse proxy is written in Rust.
In fact, better tell them to stop using the Internet altogether
>>
>>102435068
>C code is not complicated
>Even small programs can take hours to build.
>OPERATION WD-40
Amazing satire lmao. Did you write this?
I do think that "unsafe" should have been called "unchecked" though.
>>
>>102438478
>The amount of dependencies has no impact on the ease of supply chain attacks
???
>>
>>102439364
He's right. Even if you only have 5 dependencies, you're still fucked if one of them is compromised.
>>
>>102438531
There is it’s called c++
>>
>>102439437
And you think that it's equally easy to find a way to compromise one of 5 GitHub repos, as one of 100?
>>
>>102439896
Security is not a game of chance.
Dependencies that are more popular, but are maintained by a small amount of people, are the prime victims of hijacking attempts.
>>
>>102439913
So you do. You think that it's literally equally easy to find a way in when there are 5 repos as when there are 100.
>Security is not a game of chance.
It literally is.
>>
>>102439944
>you think
>it is
meds
>>
>>102439948
Just wanted a yes/no answer to confirm whether you're retarded.
>>
>>102439568
>c++
>normal compile times
>>
File: images(44).jpg (5 KB, 210x240)
5 KB
5 KB JPG
>Rust
>>
File: IMG_6171.png (40 KB, 1209x680)
40 KB
40 KB PNG
>>102440039
Still faster than rust
>>
>>102440093
>functions per second
kek
>>
>>102438595
>The Rust dev guy will be too busy fighting with the compiler
Only inexperienced programmers fight with the compiler.
>making sure to write code the compiler way
What does that even mean?
>has no choice but to reformat majority of the code(most of the time) to experiment
Reformatting and prototyping are completely different things
>write the exploit differently
You write exploits in the same way in every systems programming language.
>he has at least 20GB free disk space so that he could build his project
You don't need that much to write a malware.
>Python and Go will come out as much better tools for the job for a lot of reasons
Lmao

Conclusion: you have absolutely no idea what you are talking about.
>>
>>102439568
ywnbaw
>>
>>102438201
>satire
Considering the intelligence of ciniles who interrupted recent Linux talks, I heavily doubt this is a satire.
>>
I struggle to come up with any project ideas that would actually make sense to be made in Rust
I'm done with ~70% of the book but I find myself kinda forgetting stuff from previous chapters only reading and writing small snippets rather than doing an actual project
Any ideas? Learning it for work since we want to adopt it, but don't want to just do work-related stuff in my free time
>>
>>102440745
See >>102383287
Basically, all sorts of engines(physics, http, game), renderers, cli utilities, network stuff, cryptography libraries, etc. It's best to pick something not too challenging on first too.
>>
>>102435068
what is this
>>
>>102441391
Nothing important, just more shitposting
>>
>>102440093
That's a very low bar. A FizzBuzz-tier example of C++ ranges takes slower to compile than SQLite, an entire database engine: https://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/
>>
Interesting preprint
https://arxiv.org/abs/2409.08708

I didn't realize all the the MC/DC work in the compiler was being pushed presumably by Ferrocene and whatever other parties want to use it for Aero
https://en.wikipedia.org/wiki/DO-178C
>>
>>102440331
It obviously is you moron.
>>
>>102442850
Sure it is. I give it a week max before some ciniles start making unironic daily threads about it.
>>
>>102435068
Amazing i knew it all along.
>>
File: 39504077.png (22 KB, 280x280)
22 KB
22 KB PNG
>>102440745
I recommend making something for the Buttplug.io Sex Toy Control Protocol, which is of course implemented in Rust.
>>
>>102442945
Why are you so obsessed with this?

Emacs/lisp users were doing this over a decade ago, maybe even before your 14 year old ass was born lol
https://github.com/qdot/deldo
>>
>>102442988
>Why are you so obsessed with this?
He's a /pol/ shitposter; he thinks that everyone shares his mindrot and he literally has nothing better to do with his time.
>>
>>102443029
He’s not the vast majority of rust devs are like communist trannies really weird stuff in the rust community. They even put weird comments in their release for 1.44

> This is a shorter blog post than usual: in acknowledgement that taking a stand against the police brutality currently happening in the US and the world at large is more important than sharing tech knowledge, we decided to significantly scale back the amount of promotion we're doing for this release.

>The Rust Core Team believes that tech is and always will be political, and we encourage everyone take the time today to learn about racial inequality and support the Black Lives Matter movement.
>>
>>102442988
>Why are you so obsessed with this?
He is a faggot looking for someone to program his proprietary buttplug.
>>
>>102433501
Might be swift now. Still haven't checked swift 6.
>>
>>102443127
Do not insult me like this again. I use exclusively FOSS firmware, Richard Stallman approved buttplugs.
>>
>>102443180
Then your emacslisp implementation has been in butts longer than rust
>>
>>102443193
You're telling me that Emacs has pioneered the area of vibrating butts via computer too? Yet another win for lispchads! This is almost as important as that time in the '90s when Germany's air traffic control system was running in Emacs.
>>
>>102442914
>I give it a week max before some ciniles start making unironic daily threads about it.
RENT FUCKING FREE
What is it about Rust that makes it attract the most sad, humorless, and obsessive people, who couldn't recognize banter or satire if it hit them in the face? Looking forward to your deranged responses.
>>
>>102445122
Cniles literally say the dumbest possible thing imaginable in every thread with no sarcasm whatsoever
>>
>>102445170
>t. humerless brainwashoid
>>
>>102445201
Good job proving his point, dumbass lmao
>>
>>102445170
>no u!!!
Ah, I see that you're an adept of the Kindergartic Method. Expected nothing less. Is "your mom" the next response? Let's find out!
>>
>>102445502
Anon, you're too late.
>>102445201 already did the whole "let me show you you're wrong by acting retarded" thing.
>>
>>102445122
I really wish it was a banter or satire, but C attracts one of the most unhinged and simply ignorant sort of people. The fact that it is often the first language people learn and that usually it's more retarded part that indulges in tribalism only intensifies this phenomenon. The only other groups that could compare to them are zig fans and htmx crowd.
>>
>>102445934
>I really wish it was a banter or satire, but Rust attracts one of the most unhinged and simply ignorant sort of people. The fact that it is often the first language people learn and that usually it's more retarded part that indulges in tribalism only intensifies this phenomenon. The only other groups that could compare to them are zig fans and htmx crowd.
fixed
>>
>>102446061
See >>102445502
>>
>>102438595
>malwareS

...saar
>>
>>102442988
It's the same guy who did both though
>>
>>102445934
I actually haven't heard about htmx other than the name and that it has something to do with webdev. What is the drama about there?
>>
>>102429653
i want a cute trans woman to assume a mommy role and teach me rust
society owes me this
>>
>>102448318
Nothing wild. Just some fanatic fans trying to push it to be the next big thing. That said it actually is kinda comfy for small to midsize web pages, but nothing more.
>>
>>102448318
if you wanna skip majority of frontend bloat without js then htmx works
>>
>>102433501
>>102448390
stop watching porn
>>
>>102448674
i dont watch porn i just think trans women are cute (and should teach me rust)
>>
>>102448674
never
>>
>>102433501
It's OCaml. The syntax is very different from Rust, but it's somewhat similar in its "feel": functional concepts, but you can still do imperative stuff if you want without going through monads. It's no accident that the first version of Rust was written in OCaml.
>>
>>102448318
It's a really not well thought out idea to revolutionize web by going back to sort of PHP 2.0 that is disproportionately popular among people who don't really do professional webdev. That's not really unique by itself, there is a lot of bad ideas circulating in webdev, especially baits for people who think they can get finally make websites without learning javascript. However the community around it and especially its creator, are known for aggressive shilling, shitposting and basically non-technical nonsense. It was so bad that any discussion about the entire technology got banned on r/webdev or some other big subreddit. It's the /qa/ of webdev.
>>
>>102449558
>non-technical nonsense
hmmm
>>
>>102449558
>there is a lot of bad ideas circulating in webdev
truer words have never been spoken
>>
>>102448721
>>102448390
looks like a false flag to me tbqhwy
>>
>>102450297
UwU false flag me harder daddy
>>
>>102450297
bros is it a false flag to have romantic preferences
>>
File: 1706748383496396.png (380 KB, 720x840)
380 KB
380 KB PNG
>>102429653
I'm ready to be loved, even if it's by a trans woman. These recent years I become more and more numb to politiks, and now I just don't care if you're black or trans. I won't ever say you're valid, but I also just don't care. I heard the Rust community has a lot of trans developers so I though I would ask here. I'm 5'7" and work at a waffle house, you would be the provider but I think that is a plus because it would bend gender norms or something. I'm also open to learning programming, made a Javascript todo list following a YouTube tutorial and it was fun. I don't think I'm ready for Rust yet thought, but feel free to teach me and uh uwu is what the femboys say.
<anime spacing
>let me know if I come off too strong it's my first time ever asking out a woman
>>
>>102450618
god tier bait
>>
>>102433501
In all seriousness - C#/F#, because all other GC-based languages have dogshit performance and/or none of the features that make Rust a complete package

where-as these give you C with structs and pointers, monomorphized struct generics with interface composition, portable SIMD, APIs for manual memory management, stack buffers, iterator expressions with LINQ (you do pay for them extra but it has gotten much better), async, Task and structured concurrency with task composition without any lifetime pain whatsoever, Parallel == Rayon, Channels, native compilation and static linking over C FFI into Rust or vice versa with NativeAOT, speaking of FFI - it can be zero-cost or almost zero-cost, you also have proper package manager, nice to use CLI that is almost identical to Cargo and sane project manifests (csproj is xml but minimalistic, it's not java with pom.xml madness)
>>
>>102435068
>it has reference counting
>syntax complaints
>80s language theory
>storage space fears
>misunderstanding unsafe
>marxism
Great satire, thanks for the laugh
>>
>>102445201
>>102445502
The linux video where the rfl guy stepped down had one guy thinking Rust was Java pOOP
>>
Bump
>>
>>102450618
>I'm 5'7" and work at a waffle house, you would be the provider but I think that is a plus because it would bend gender norms
Amazing lmao
>>
>>102439364
It has no impact. 500 lines of code spread over 100 dependencies is the same amount of attack surface as 500 lines over 5 dependencies, or over just one.
If anything, larger dependencies tend to have code with overlapping functionality, prime example is something like string handling in C libs. If you have three large dependencies written in C, chances are all of them have their own versions of exact same helper functions for strings. Even if said dependencies actually depend on each other, since "string handling" is not part of the library's goal, so none of them expose these function to dependents. This does actually increase the attack surface vs using a shared micro dependency.
>>102439896
Counterpoint - the smaller the dependency, the harder it is to covertly insert compromising code, and the easier it is to review any changes for maintainers. The amount of maintainers in projects doesn't scale linearly with the size of the code, it plateaus at some point, so more packages = more maintainers, yes, but more maintainers = more people looking at the code too.
>>
>>102440745
"Zero to production in rust" is a nice bridge from knowing the language to making projects in the language
>>
>>102440745
>I'm done with ~70% of the book but I find myself kinda forgetting stuff from previous chapters
Do people actually do this? Why???
Literally just make stuff and look up relevant things in the book.
>>
>>102451761
I'm a C programmer, but that was pretty pathetic :(
>>
>>102454108
I'd add Rust by example. It's more learning rather than advancing stage though.
>>
>>102454069
>It has no impact. 500 lines of code spread over 100 dependencies is the same amount of attack surface as 500 lines over 5 dependencies, or over just one.
retard
repos owned by more people = more chance that someone fucks up git security
>>
>>102454493
And yet, XZ caused more disruption than anything on cargo and npm combined.
There is also aspect of version pining and that package repositories require 2FA and other stuff, while plain old system packages do not get verified.
>>
>>102435068
OH NONONOO RUSTOIDS?
>>
File: 1725411931970859.jpg (63 KB, 333x766)
63 KB
63 KB JPG
>>102438201
Cnile baby ducks have exhausted all my good will. From now on if it quacks like a retard it's a retard.
>>
>>102445122
>What is it about Rust that makes it attract the most sad, humorless, and obsessive people
I am really not sure, but I agree. The Cnile seething is getting out of hand and that they should really do something more productive with their lives. Never have I seen a language attract this amount of midwits frothing at the mouth to "debunk" something many of them don't even have the mental acuity to learn.
>>
>>102440093
this benchmark is manipulated to make Rust look good. Not a fair comparison by any means.
>>
>>102440223
>Only inexperienced programmers fight with the compiler.
and only inexperienced programmers will fall for memory pitfalls like buffer overflow. Memory safety is a matter of experience, not language. Even inexperienced Rust programmers can create memory bugs in Rust. Still, the amount of time it takes to become experienced enough to hold your ground against the compiler is not worth it when other languages get the job done straight away.
>What does that even mean?
the compiler forcing one to format the code the way it wants is something that any experienced dev will find to be absolutely stupid.
>Reformatting and prototyping are completely different things
who said it isn't? but you wouldn't want to perform tests on poorly refactored prototypes, would you? maybe you would but I wouldn't. I want to make sure that a certain approach is not the right solution whenever I prototype something.
>You write exploits in the same way in every systems programming language.
no. For a fucked up language like rust that is clearly garbage collected and yet claims that it isn't, things get more complicated. You can't do any low-level stuff in rust without using unsafe and that only doubles the amount of work to get the job done. C on the other hand provides a straight solution for anything low-level.
>You don't need that much to write a malware.
yeah, maybe not but the dependencies probably do.

Conclusion: you have no proper programming experience in any programming language and lack a decent exposure to programming.
>>
>>102455610
That's a lot of words to tell us you don't know anything about rust my man. You could just have said
>I don't know anything about rust.
>>
>>102438201
>Zommers can't even identity satire anymore when it's slapped in their face.
Ok anon. Could you tell me if this is supposed to be a satire? >>102455610
Because I genuinely doubt he is just pretending to be this retarded.
>>
File: 1692853826516213.png (9 KB, 480x678)
9 KB
9 KB PNG
Are there any plans to allow defining macros in regular projects? Any research being done on that? Derive macros can be particularly great in some situations but it's a chore having to create a new crate for them.
>>
>>102455857
We are going to have macros 2.0 but they are just better macro_rules, procedural macros will probably remain as is.
It's not really that much of a deal to nest crates. You can just keep it in a subfolder with its own Cargo.toml. After all your procedural macro will have very different dependencies and source files than the rest of the project. I just have a `derive` folder in my project root where I keep my procedural macros.
>>
>>102455925
Ok, thanks. The reason I'm asking is because the rust book mentions that the restriction might be lifted in the future.

Another macro related question for the thread: do people generally use procedural macros much? They seem really useful for implementing traits which implement really simple getter methods for other more complex traits to use.

Like in gamedev if I have a Creature trait which has methods to retrieve a Creature structure, which is present in all creatures in the game. Using derive to implement all that shit could save a lot of lines, and would kind of give it an inheritance feel. Is this retarded?
>>
>>102456126
>Another macro related question for the thread: do people generally use procedural macros much?
They aren't needed unless you are doing something big or a library with some QoL macros like serde.

I personally only used procedural macros twice, both in my game engine.
First was to automatically generate --help message from doc comments and some reflection boilerplate for parsing args.
For the second, I wanted to have unity like components for my entities. All the components share some common logic, like id, entity attaching, life cycle etc. I store all that state in a ComponentInner struct that is present in every component by composition. I made a macro that derives ComponentBase trait for that struct, so you can write:
#[derive(ComponentBase)]
pub struct Glow {
#[inner] inner: ComponentInner,
pipeline: Arc<GraphicsPipeline>,
color: Cell<Color>,
size: Cell<f32>,
}

and it automatically implements these methods:
pub trait ComponentBase: Any {
fn inner(&self) -> &ComponentInner;
fn inner_mut(&mut self) -> &mut ComponentInner;
fn as_any(&self) -> &dyn Any;
fn name(&self) -> &'static str;

And then all you have to do is just implement lifecycle methods:
impl Component for Glow {
fn start(&self, entity: &Entity, _application: &Application) -> Result<()> { ... }
fn render(&self, entity: &Entity, context: &mut RenderContext, _renderer: &mut Renderer) -> Result<()> { ... }
fn on_inspect(&self, _entity: &Entity, ui: &mut Ui, _application: &Application) { ... }
...
}

>They seem really useful for implementing traits which implement really simple getter methods for other more complex traits to use.
Bingo. It's how you can get reflection, attributes, doc comments and such.
>>
>>102456267
>I personally only used procedural macros twice
wrote*
I use a lot of macros from libraries of course.
>>
>>102456286
Maybe? But I imagine it would be pretty hard to follow.
Like, could you show me an example of macro_rules that can find a field marked with #[inner] and generate a getter for that field?
>>
>>102455321
it's not the same people, just junior year students cycling through these threads
>>
File: gjson.png (17 KB, 297x264)
17 KB
17 KB PNG
It should be /rplg/ not /rust/ idiot
>captcha: GJS0N
>>
>>102454526
actually version pinning is a decent point
>>
>>102456323
>But I imagine it would be pretty hard to follow.
yea macro_rules is very much "write once" type of thing
Too lazy for an example, but derive and #[attribute] is proc macros, a macro_rules solution's usage would be something like
implComponentBaseFor!(Glow, inner)

instead of annotating a type you make the implementation of the trait "generic" over a type and member name, then "instantiate" that impl with the specific values you want
>>
>>102456450
Welp, this looks kind of weird, but I guess it might work.
This won't work with the first usecase of generating --help from doc comments though.
>>
>>102456450
I thought about this too, but it seems way more convoluted in both implementation and usage. Yes you need a whole new crate for the alternative, but still.

I don't know a lot about macros though.
>>
>>102435068
look at Microsoft!
>>
File: .png (116 KB, 1200x2200)
116 KB
116 KB PNG
>>102440223
>Only inexperienced programmers
The "skill issue" argument is always retarded, no matter which direction it's used in. You know what's also a skill issue? You not being good enough at C to always write memory safe code. Actually, if you couldn't write Roller Coaster Tycoon in pure assembly, you have no business talking about "skill issues".
The entire point of higher level languages is to be easier and more productive, which is why the logical end point of all "skill issue" arguments is that we should all use Java or Kotlin. Java is so easy if you don't fall for the memes about "elegant" OOP designs with 7 layer inheritance hierarchies. If you write grug level, brutally simple procedural code, writing Java is like playing Stardew Valley. It's relaxing, it's pleasant, it just flows. In comparison, trying to get anything done in Rust is like playing chess and League at the same time. Both in terms of mental exertion and insufferable people constantly yelling at you over the Internet.
>>
>>102456536
I don't struggle with Rust compiler and I never write memory unsafe C.

What is your point even?
>>
>>102435068
why do you think they named it Rust? it's predictive programming - when a machine Rusts, it breaks!
>>
>>102455649
instead of saying I don't know anything about rust, you could have simply said that you only know of bit of Rust and nothing else.
>>
File: 1718736537081012.gif (1011 KB, 264x320)
1011 KB
1011 KB GIF
>>102446965
>>
>>102456355
/rust/ is catchier and there's no risk of overlap
>>
>>102455739
those are legitimite criticisms
>>
>>102457280
So it's not supposed to be a satire. Lmao, I knew it.
>>
This general was more fun when it was the helpful rust thread /hrt/
>>
>>102457363
this is general?
there are like, at least 4 rust threads on all the time. Either it must be my fault for failing to keep track of them or its not my fault if there are too many for me to keep track of.
Somebody's got to get their shit together for thing to return back to the way they were and it definitely ain't me.
>>
>>102457363
Don't worry, the /pol/ shitposters will get tired eventually.
Besides, the last few threads were pretty decent.
>>
>>102457618
>doesn't like Rust
>keep track of every single Rust thread on the board at any time
Mental illness.
>>
>>102457659
>if you don't like Rust you must be /pol/
What kind of brain rot is this?
>>
File: garbage.png (411 KB, 514x616)
411 KB
411 KB PNG
>>102457693
>namefag
>>
>>102457696
He claimed nothing like that. It's you who assumed that.
What brain rot do you have then?
>>
>>102457749
Please do not feed the mentally challenged troll.
>>
>>102457772
Just making fun of him. He is too retarded to respond anyway.
>>
>>102457778
>Just making fun of him.
DO NOT. FEED. THE TROLL.
It's literally that simple, anon.
The more just you "teehee" him, the longer he stays.
>>
File: file.png (40 KB, 685x242)
40 KB
40 KB PNG
>>102435068
Lobbying has been taken to a whole new level in this day and age.
>>
File: file.png (68 KB, 681x344)
68 KB
68 KB PNG
This text reads like extreme Chinese ESL, but he knows exactly what's up
>>
>>102438595
saar stop seething about jai and rust because they're actually good languages. go write something in odin.
>>
>>102438547
What the fuck are you talking about you baboon? A backdoor in xz went undetected for a long time, and you expect your half-assed "antivirus" will pick up a hand-crafted exploit like that?
>>
>>102442914
>>102440331
>ciniles
>ciniles
You remind me of flat earthers calling normal people "globetards" or how psyopped boomers speak.
I wonder if the same handbook is being used to craft both narratives.
>>
>>102457693
I look like this, I say this, and I do this.

>>102457681
This also.

Thank you.
>>
>>102456267
This unreadable shit is shaping your brain wrong. Literal demonic mind viruses encoded in plaintext.
>>
File: file.png (3.98 MB, 1800x1162)
3.98 MB
3.98 MB PNG
>>102459050
crabs got shooters, watch yo back
>>
File: RPEA8XW1XQR5.png (62 KB, 420x420)
62 KB
62 KB PNG
>>
>>102459050
source?
>>
>>102459114
>they're actually good languages
so what? just because they are good doesn't mean that they should be perfect.
>>
File: seriouis_hat_fact.png (84 KB, 775x1232)
84 KB
84 KB PNG
>>102457681
>doesn't like Rust
who said I didn't like Rust? Rust is annoyingly good.
I was just pointing out a few downsides of Rust and all i got in return were retarded claims about me instead of about what I said.
>>
Anons... I just discovered Rocket after years of avoiding Rust and doing all my web apps in Go/C#...

I think I'm ready to give in. Time to put the programmer socks on, it's too good.
>>
>>102460745
>Time to put the programmer socks on
No need for that here, anon.
Believe it or not, you CAN write software using Rust without being part of the group that develops it.
>>
We're para-virtualizing now, bros
https://techcommunity.microsoft.com/t5/windows-os-platform-blog/openhcl-evolving-azure-s-virtualization-model/ba-p/4248345
>>
>>102461662
I was forced to work with Azure once.
NEVER. AGAIN.
I will literally choose starvation over having to work with Azure cultists.
>>
>>102457749
He's been claiming this. Read the thread moron.
>He's a /pol/ shitposter
>>
>>102454356
never alpolgize for who you are
>>
>>102459050
Do we actually know that it was a Rust user who called in the police?
>>
>>102460745
You mean Racket?
>>
>>102462691
no, trolls swat anyone livestreaming
>>
I am getting filtered by iterators
like yeah I could just for loop everything but...
>>
>>102463059
what's got you filtered? i've written some horrendously idiomatic iterator one-liners in my day
>>
>>102463120
just a lot of ways to iter and lots of data structures that can be itereted that act differently. Lots of moving parts to remember. I am way too used to just using for loops
>>
>>102463213
scroll through the iter and slice doc nav panes periodically to familiarize yourself with the methods, you might realize what you need some day in the future. i do it to catch up on things that might have stabilized or see unstable things and possibly push to get them stablized
https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html
https://doc.rust-lang.org/stable/std/primitive.slice.html

other data structure store is just usage over time committing to memory. if this is your first language with map and filter then it's definitely an adjustment period but eventually becomes more natural
>>
>>102463213
Fundamentally iterators are just fn next(&self) -> Option<T>. It's all the same for every data structure and such. All other functions are build on top of it. There is nothing here to remember, except maybe basic functional methods like map, filter, chain, zip, etc.
>>
>>102463333
>&self
&mut self
>>
How did Rust pinning become so clusterfucked? It makes no sense that a mutable reference gives you both the capability to mutate and to move, and then you have to do weird trait voodoo shit to remove the capability to move. There should just be three types of pointers. Regular (can't mutate, can't move), mutable (can mutate, can't move), turbo mutable (can mutate, can move).
>>
>>102464240
>It makes no sense that a mutable reference gives you both the capability to mutate and to move
Practicality. I don't see the other way of always having to add a move trait any better
>>
>>102464288
They could have just made three types of references instead of two. Like, I don't know, ref, mut ref, and mov ref (the last one being what mut ref is now). That would cause no extra boilerplate.
>>
>>102464428
&& electric boogaloo
>>
>>102464240
Well, you can't actually move out of a mut ref because moves are destructive and mutable reference can still exist due to reborrowing, which would mean it outlives the object.
>>102464428
mov ref would have to remove the object it's created from and forbid reborrowing, at which point you've basically arrived back at moving, but explicitly done via reference instead of relying on the compiler to optimize move to pass a pointer around
>>102464835
There is missing functionality for forcing move by reference. Though it would be easier done by just using the move semantics and introducing a compiler builtin RefMove<'a, T> that guarantees same size as *mut T
>>
>>102457681
I look like this, say this, and do this
>>
File: 1717284984401737.jpg (4 KB, 228x221)
4 KB
4 KB JPG
>>102456850
>no risk of overlap
you'll be fucking hearing from fellas over at Rhumba Ultimate Secondary Troop (dance club)
>>
in async, how do i decide when a value should be returned from the function or sent through a channel?
>>
>>102462726
no. he really meant Rocket
https://www.rocketlanguages.com/
I recommend it for learning Rust too. It still did take a lot of time to learn Rust with Rocket and that is completely Rust's fault.
>>
>>102460356
It's LITERALLY in the post I quoted you fucking zoomer. You probably didn't even finish reading this post because it has too many words. Go ask ChatGPT for a summary.
>>
>>102455610

>Still, the amount of time it takes to become experienced enough to hold your ground against the compiler is not worth it when other languages get the job done straight away.
If you do not make a habit of learning for enjoyment, you should not be a programmer.
>>
>>102467467
I think you might be linking to the wrong Rocket.
https://rocket.rs/
>>
>>102467993
Yeah this is the one.
>>
Axum > Rocket

For one man projects, do consider loco.
>>
>>102467286
return value
and
channel.send(value);
?
>>
>>102469213
I think he's more asking when he should use these two.

>>102467286
Typically if you need the underlying function to keep running you will use channels. This is the same as any other language, so general rule of thumb: if you CAN return, then do. Use channels as a last resort.
>>
>>102467993
Don't reply to the astroturfer anon. That person doesn't even know rust.
>>
>>102466515
heh
>>
>>102432040
how come ?
>>
>>102469799
That anon you're replying to is shitposting.
He does not actually know anything about Rust, but is hellbent on shitting on everything related to it because most developers behind rust are queer.
>>
>>102469838
They aren't. Stop using twitter and go outside.
>>
File: c.png (148 KB, 2292x1638)
148 KB
148 KB PNG
>>102429653
In case the anon who originally wrote this visits this thread: cunny_rs, external dependency-free.
fn main() {
println!("{}", (0..33).map(|col| (0..36).map(|row| (3..39).map(|x| ((f64::from(x) % 22.0 / 3.0).cos() / 5.0).mul_add(-15.0, 16.0).round() as usize).map(|x| [["```"].repeat(x), vec!["@@@"], ["@@@"].repeat(32 - x)].concat()).rev().collect::<Vec<_>>()[row][col]).collect::<String>()).rev().fold(String::new(), |acc, x| acc + &x + "\n"));
}
>>
just use OCaml
>>
>>102469995
based, it's been too long since I worked with complex numbers so I didn't think about just using the real number equivalent

made a much simpler version as well, although the output is mirrored
(0..36)
.map(|i| (3..39)
.map(|x| ((f64::from(x) % 22.0 / 3.0).cos() / 5.0)
.mul_add(-15.0, 16.0)
.round())
.map(|x| (x < (33 - i).into()).then_some("@@@").unwrap_or("```"))
.collect())
.collect::<Vec<String>>()
.join("\n")
>>
>>102459090
>the new normal instead of GNU/POSIX
GNU is only "normal" because it's popular. POSIX is a spec.
>bashisms are a thing
>GNU AWK isn't True AWK
and nobody complains. why?
>>
>>102441876
Not surprised at all, ranges is a trash tier feature promoted by those who want to sabotage C++. Only faggots use it.
>>
>>102459090
GNU isn't POSIX compliant. If you follow this logic, you could say that GNU was the embrace, extend and extinguish of POSIX. But then, what point are you even trying to make? Throw random terms to convince midwits that crab bad?
>>
>>102469995
>>102470698
What the fuck bros.
>>
>>102459090
>Subtle incompatibilities
>Noooo, if the old software was shit you can't just write and improvement for it, your new software has to be shit also
lol
>>
>>102470698
LMAO, only a crackpot can believe that is readable or maintainable.
Pure mental illness.
>>
>>102470855
Filtered
>>
>>102470698
>although the output is mirrored
Literally just reverse the lines before collecting them.
(0..36)
.map(|i| (3..39)
.map(|x| ((f64::from(x) % 22.0 / 3.0).cos() / 5.0)
.mul_add(-15.0, 16.0)
.round())
.map(|x| (x < (33 - i).into()).then_some("@@@").unwrap_or("```"))
.rev()
.collect())
.collect::<Vec<String>>()
.join("\n")


>>102470855
Skill issue.
>>
>>102470855
Show us the version in your shitlang in which you make it way more "maintainable" by introducing 4, 5 variables into scope and a bunch of new functions while being 10 times as slow.
>>
>>102470799
>>102470855
It's a Rust implementation of cunny.py:
print("\n".join(reversed(["".join(i) for i in
list(zip(*reversed([["```"] * j + ["@@@"] + ["@@@"] * (32 - j) for j in
list(map(lambda x: round((2.7**(x % 22 / 3 * 1j)).real / 5 * -15 + 16),
range(3, 39)))])))])))


Also a Clojure version:
(->> (range 3 39)
(map #(-> %
(mod 22)
(/ 3)
(Math/cos)
(/ 5)
(* -15)
(+ 16)
(Math/round)))
(map #(concat (repeat % "```")
["@@@"]
(repeat (- 32 %) "@@@")))
(reverse)
(apply map vector)
(map #(apply str %))
(reverse)
(map #(str % "\n"))
(apply str)
(print))
>>
TL;DR: Want to track heart rate via ECG with lots of storage or an accurate fitness device with a good enough ppg sensor group to give me reliable trends.

I want a recommendation on my kettlebell journey, it's a strength endurance workout and my miband 7 jumped in one second to the other from 142 BPM to 182bpm.

I might need a better alternative to look into or to research.

The polar H10 sounded good until I found out it can only cache one workout every time.
So my next best bet seems to be looking for the best PPG sensors money can buy to track my workout and give me a good enough estimate as I try to force matter and anti-matter to copulate for 30 minutes 4 times a week.

Chinese brands are also cool with me as long as I can connect them with Google health connect.
>>
>>102472271
Don't worry, anon. We all make mistakes.
>>
>>102472339
Wow, you are the first person to be nice to me the last two months.
I hope you have a wonderful weekend.
>>
Forgot to say,
>>102470698
Really nice, anon. It's pretty impressive that a high-performance statically-typed systems programming language can be as expressive/concise as a high-level dynamically-typed language.
I'm going to start learning Rust this weekend.
>>
>>102467993
>I think you might be linking to the wrong Rocket.
yes and it was an intentional joke.

>>102469262
>That person doesn't even know rust.
true. I only spent a little over a year with Rust which is too little time to claim that I know that language.
All I did was use tokio's reqwest as the back end for a client while ELM was the front end and debug with tracing. I only did stuff like handling API endpoints with postgres(with out ORM. Its a fucking cancer), user authentication and authorization, real time updates using server sent events and a few more.
I haven't done any computer graphics stuff in Rust and I probably never will as Rust is clearly the wrong tool for the job.
>>
>>102468375
this. If anyone is new to Rust, I'll direct them towards Axum. So much can be done within so little time.
>>
i ran into this today.
https://github.com/rust-lang/rfcs/pull/447

So instead of doing this
struct Foo<T, U: Bar<T>> { foo: U }

Despite the fact that T is used you have to instead do
struct Foo<T, U: Bar<T>> { foo: U, _marker: PhantomData<T> }


PhantomData of course is a special exception allowed by the compiler. Also the age of some of the language feature issues I run into are worrying. See:
https://github.com/rust-lang/rust/issues/8995
https://github.com/rust-lang/rust/issues/29625
>>
>>102472709
yeah, the marker pattern is weird at first but you learn it once then get over it. makes sense you can't be generic over an unconstrained type

imo it's not really worrying since they're more architectural issues, the type team and others have been overhauling things with a more informed sense of the problems that weren't seen when it was first being built. things like the new trait solver will fix some longstanding issues but there are only so many resources and people able to work on this. sometimes the issues are edge cases and a worse way of doing things, they'd rather not rush to stabilize more things in a broken state.
>>
>>102473054
To me it doesn't any sense at all that the compiler wouldn't just act as if you did the second anyway because you can't use bar as a constraint without giving it a type. For type resolution, rust is monomorphic so it should be a different type as long as the two types are different. C++ doesn't have this issue with constraints if I'm remembering correctly. I mean I'll get over it, but it is clearly a wart. It might have something to do with how rust resolves types that I'm just not aware of.

Thanks for the other information though! I've been using rust on and off for years so I always forget things when I come back to it.
>>
>>102472545
NTA, but we still don't have HKTs and therefore monads and such, But the Iterator, Option, Result and such interfaces are well thought-out and very composable. I personally find Rust to be in a nice sweetspot between functional and imperative approaches.
>>
>>102470855
>readable or maintainable
those weren't the goal
>>
File: cat pillow.jpg (91 KB, 775x725)
91 KB
91 KB JPG
>>102472529
>I hope you have a wonderful weekend.
Same to you!
>>
I just clone all the time and there isn't shit you can do about it.
>>
>>102438636
>and how it can often times evade detection.
is this because of monomorphization and the fact the malware scanners just aren't use to rust emitted code?
>>
>>102474413
>rust emitted code
It's all so tiresome...
>>
>>102473379
C++ generics are basically duck typing and resolved completely differently than Rust generics. It's way more loose and excepting of things without any constraints
>>
>>102435068
The absolute state of /g/ with its daily seethe thread is preventing me from considering that this is 100% satire, more like 95%, and even that is already a sorry state.
>>
>>102474487
Concepts do have constraints and that's what I was referring too. It isn't that big of a deal though.
>>
It's ok to project a pin on an enum onto the variant, right?
like

enum X {
Socks5(SomeFuturesReadableSocksThing),
Tcp(SomeFuturesReadableTcpThing),
}

... impl for futures read/write/poll here.


since futures traits require self to be Pin<_>. I only ask since getting the "unpinned" interior to repin requires unsafe.
>>
>>102474759
file:///usr/share/doc/rust/html/std/pin/index.html#projections-and-structural-pinning

I'll just read this for now.
>>
>>102429653
Does programming language really matter anymore when you can just ask AI to write it and maintain it?
>>
>>102475339
Nope. However, we aren't there yet.
>>
>>102474746
Switft also has generics with restrictions. It's quite lovely.
// Function to find the maximum element in an array of Comparable elements
func findMax<T: Comparable>(array: [T]) -> T? {
guard !array.isEmpty else { return nil }

var maxElement = array[0]
for element in array {
if element > maxElement {
maxElement = element
}
}
return maxElement
}

// Example usage with Int (conforms to Comparable)
let numbers = [5, 2, 9, 1, 7]
if let maxNumber = findMax(array: numbers) {
print("Maximum number: \(maxNumber)") // Output: Maximum number: 9
}

// Example usage with String (conforms to Comparable)
let strings = ["apple", "banana", "orange"]
if let maxString = findMax(array: strings) {
print("Maximum string: \(maxString)") // Output: Maximum string: orange
}

// Attempting to use with a non-Comparable type would result in a compile-time error
// struct MyStruct {}
// let myStructs = [MyStruct(), MyStruct()]
// let maxStruct = findMax(array: myStructs) // Error: MyStruct does not conform to Comparable
>>
>No higher kinded types
>No refinement types
>No linear types
Why learn this basic language?
>>
>>102472271
Lost /fit/ poster? Or do you intend to create an ECG device with Rust firmware?
>>
>>102456598
>I never write memory unsafe C
Sure buddy
>>
>>102476323
to break the heart of god
>>
>>102476323
What language can I use with all of those? I'm sure it's quite mainstream and has a healthy ecosystem
>>
>>102478599
Liquid Haskell
>>
>>102478871
knew that was gonna be the answer lmao
>>
>>102478947
Do you also code in Haskell 98? (By which I mean Haskell with 98 language extensions enabled)
>>
>>102472709
I actually figured out how to do it without phantom data but it is kinda jank.
trait DummyTrait<T,  U: Bar<T>> { type T; type U; }
struct DummyStruct;
impl <T, U: Bar<T>> DummyTrait<T, U> for DummyStruct { type T=T; type U=U; }
struct Foo<T, U: Bar<T>>{ foo: <DummyStruct as DummyTrait<T, U>>::U }
>>
>>102475468
>
guard !array.isEmpty else { return nil }

why this instead of
if array.isEmpty return nil
>>
>>102472709
It's probably because T: Trait<U> doesn't give you any variance information in regards to U
>>
Is it a bad idea to learn Rust before C?
>>
>>102485177
Eh... not necessarily, but with some caveats. You don't need to know C to understand Rust. Knowing C or C++ will give you a background in systems programming that will make learning Rust easier, but you can learn the basics of systems programming through Rust just the same. It is still worth knowing C after learning Rust though, since there's a lot of open source applications written in C, which are worthwhile to study.
>>
>>102485177
No. Starting in either will make for a less painful entrance into the other.
>>
I've managed to get an error message that looks like this, using quite simple language constructs, mostly unwrapping an enum I created to a type that I created within a closure.
fmc(51998,0x1fe52cf40) malloc: Heap corruption detected, free list is damaged at 0x600002e9f090
*** Incorrect guard value: 188586804572160
fmc(51998,0x1fe52cf40) malloc: *** set a breakpoint in malloc_error_break to debug


I've decided to redesign how it works, but is an error like this something that I should report?
>>
>>102485177
Whichever way you go, the second one will probably be easier than the first one, just because you'll be better at programming by then.
For C, I recommend C Programming: A Modern Approach by K. N. King. For Rust, just use the Rust book.
>>
>>102485665
are you getting this when running your code or the compiler? Release or debug build?
>>
>>102486311
Both debug and release. All runtime.
>>
>>102435068
90 IQ syntax
>>
>>102441498
>further proof your tranny language is bs
>"BLAH BLAH BLAH I CANT HEAR YOU"
>>
>>102486603
it's obviously humorous dude
do zoomers really need a SATIRE watermark across the whole text to tell
>>
>>102486517
huh... are you unwrapping an error?
>>
>>102482785
Not really when some thing like this compiles: >>102480423
The explicit alias of type T in the trait isn't even needed as traits seem to be less strict about type usage. It's just a deficiency in the compiler and adding an extra layer of indirection does the trick. There was something like this in c++ where you couldn't add a static_assert that are always false (to prevent unspecialized compilation) without using a template variable to add indirection.
>>
>>102487166
nah I think that would cause a panic, no?
>>
>>102487187
>There was something like this in c++ where you couldn't add a static_assert that are always false (to prevent unspecialized compilation) without using a template variable to add indirection
Even in templated class static_assert in class or static function scope was being emitted. You had to put them in a virtual dtor to make the static assert emission conditional to emitting the class
>>
>>102485665
Yeah, that's pretty bad and definitely worth reporting, assuming you aren't doing weird shit with unsafe. Can you turn it into a minimal reproduction?
I'm guessing you are using Box or some container at least?
>>
>>102487480
I'm actually not doing any of my own memory management with the type. the "unwrapping" that I mentioned is really just a clone which is one reason why I'm redesigning it. The type has Strings and Vecs in it.

The wrapper and the type itself:
#[derive(Debug, Clone)]
pub enum ChunkType {
Modification(Chunk),
Unchanged(Chunk),
}
impl From<ChunkType> for Chunk {
fn from(chunk_wrapper: ChunkType) -> Chunk {
match chunk_wrapper {
ChunkType::Modification(chunk) | ChunkType::Unchanged(chunk) => chunk,
}
}
}

#[derive(Clone, Debug)]
pub struct Chunk {
pub offset: u16,
pub ctype: InstructionType,
pub opcode: u16,
pub data: Option<BlockStorage>,
pub ref_data: Option<BlockStorage>,
pub path: Vec::<String>,
pub ref_simple: Option<u16>,
pub segment_idx: Option<u8>,
}


corruption site:
                let path = vec!["3", "16", "1", "1"];
let ui_chunk = leaf.chunks
.iter()
.position(|wrapper|{
println!("Gets here.");
let chunk = Chunk::from(wrapper.clone());
println!("after unwrapping.");
if chunk.path == path {
let mut n: Vec<u8> = vec![];
if chunk.ref_simple.is_some_and(|r| r == 16) {
if chunk.data.is_some() {
n = chunk.data.unwrap().lookup_from_buffer(&leaf_buffer).unwrap();
println!("n: {:?}", n);
let decoded = get_int(&n[n[0] as usize..]);
return decoded + 128 == table.id
}
}
}
return false;
});

doesn't reach second print. will build minimal example.
>>
>>102487697
Are you using any third party crates or unsafe code at all? You don't necessarily need to do your own memory management to trigger this, it might for example happen if you read a Vec or String from a raw pointer when you should be casting the pointer to a reference instead.
I don't see anything fishy in the code you've posted for what it's worth.
The place where it crashes doesn't have to be the place where you made the mistake. If you can run it in Miri then that may give you more info: https://github.com/rust-lang/miri
>>
Honestly the troon infestation is even MORE reason to learn Rust so that you can call them faggots to their faces at conferences.
>>
File: 1726551744745763.png (1.34 MB, 896x1088)
1.34 MB
1.34 MB PNG
Hello thread, question about signals: does the standard library provide any way to handle signals? Most articles online mention using an external crate, but I wanted to avoid dependencies. ChatGPT mentioned the libc bindings, is that the only alternative?

>>102485177
I think so, you kinda need to know how to do things the traditional way to appreciate the alternative, I think.
>>
>>102487802
Those two are your sanest options. Technically you can also write your own libc function prototypes or make sycalls using inline assembly but the standard library doesn't have anything.
I've used the libc bindings to do very basic SIG_IGN/SIG_DFL setup.
>>
>>102487756
I updated my cargo toolchain in order to get Miri installed and now it seems to work as expected. Guess someone picked it up before I did. Thanks for the help Anon.
>>
>>102487884
Thanks.
>>
>>102487201
It should, I'd ask on their zulip whether they want the deets or it's you doing something wrong
>>
>>102487971
probably an incremental compilation bug
>>
https://youtube.com/watch?v=MZdxbf0_fPg
>Rust is autistic
It finally makes sense why theres so many rust trannies
>>
>>102487697
>if chunk.ref_simple.is_some_and(|r| r == 16) {
> if chunk.data.is_some() {
> n = chunk.data.unwrap()
Just use if let. You can check all of this and remove unwrap in one line.
Something like
if let Chunk { ref_simple: Some(16), data: Some(data) .. } = chunk { ... }

Also you can compare Some(16) == value too instead of using is_some_and too.
In general, you should design your code in a way that you should rather avoid unwraps unless you are 100% sure it will never fail. If you want to panic in sort of assert way use expect instead. If you are dealing with Result then it's often better to propagate the error so you can handle it later.
Instead of
>>
What GUI should I use for Rust (on Windows)?
>>
>>102490054
egui if you want immediate mode, or iced. I haven't used the later but people recommend it often.
>>
>>102487765
This, but call them faggots while railing them from behind.
>>
>>102490183
Already happening at CppCon
>>
>>102429653
Can I release a crate on github and import that trait from GitHub instead of crates.io?
>>
>>102491433
Yeah, local paths too
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories
>>
>>102429653
How come rust has no input!(...) macro?

macro_rules! input {
() => {{
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).unwrap();
buffer.trim().to_string()
}};
($msg:expr) => {{
print!("{}", $msg);
input!()
}};
($msg:expr, $($arg:tt)*) => {{
print!("{}", format!($msg, $($arg)*));
input!()
}};
}


It's that easy to make.
>>
>>102491581
Interactive prompts for input are common in like beginner book exercises but I don't even remember when I last wrote one, usually I take input from command line arguments or files or something. It's just not that commonly useful.
If you do use it a lot it's nice to have in your personal toolbox of course.
>
print!("{}", format!($msg, $($arg)*));

This can be a bit more efficient with format_args!() instead of format!(): https://doc.rust-lang.org/std/macro.format_args.html
>>
>>102491581
https://github.com/rust-lang/rfcs/pull/3183
https://github.com/rust-lang/rust/pull/75435
https://github.com/rust-lang/rfcs/pull/3196
>>
I have accepted the rust superiority, but I have fucking forgotten how to learn a new language
>>
>>102491639
How are they done for cli apps in rust?

I'm new to rust but I am making a build script that takes in parameters similar to the way npm does it.
>>
>>102492094
there are a bunch of cli arg parsing crates from more to less "bloated" depending on what you want. with things like clap at one end and pico-args at the other

i used to use structopt but it got absorbed into clap, now i just use the structopt bits of clap where you define a struct and derive the trait for it
>>
>>102492203
forgot to say, that's if you're building an application and want an extensible interface

if you're just looking to take in whatever you pass to the binary, you want one of these then use it like `std::env::args_os().skip(1)` unless you wanted the program name
https://doc.rust-lang.org/stable/std/env/fn.args_os.html
https://doc.rust-lang.org/stable/std/env/fn.args.html
>>
based jon
https://www.youtube.com/watch?v=64t-gPC33cc
>>
>>102489798
Adding to this, another useful technique to de-clutter wrapper type code is simply creating accessors for commonly used things that involve matching:
impl ChunkType {
pub const fn chunk(&self) -> &Chunk {
match self {
ChunkType::Modification(chunk) | ChunkType::Unchanged(chunk) => chunk,
}
}
pub fn path(&self) -> &[String] {
self.chunk().path.as_slice()
}
}
>>
>>102491935
Make stuff. People usually do leetcode challenges or stuff like Adevnt of Code.
Start small, grow gradually.
>>
>>102491935
https://docs.rust-embedded.org/discovery/
https://docs.rust-embedded.org/book/
I ordered stuff relating to this. I've done a lot of embedded stuff already, but I am going with from 0 just because I never really did it at home and I wanna do these small stuff in rust
>>
File: EvBca6OXIAEaOoH.jpg (246 KB, 1080x1080)
246 KB
246 KB JPG
>>102492203
>just use a crate bro!
>>
rust
>>
>>102490054
Just use tauri if it is something serious
gtk bindings are really good but gtk crossplatform is a lie
Anything else doesn't support important stuff like virtual lists (important for memory consumption) or different language scripts
>>
>>102494707
>Anything else doesn't support important stuff like virtual lists
https://docs.rs/egui/0.25.0/egui/containers/scroll_area/struct.ScrollArea.html#method.show_rows
>>
I'm having problem with tcp streams. I'm able to send a message but I'm unable to get a response after even through tcpdump indicates that my pc got the response immediately. It's a basic tokio tcp stream. It listens to incoming messages in a loop,
>>
>>102494808
Post minimal reproduction
>>
>>102494164
i literally told you to suck the command line args anyway. i don't want to roll my own argparse shit in any language
>>
>>102494164
You can roll your own options parser but it'll probably end up wonky and nonstandard
No options parser in the stdlib unfortunately
>>
>>102494806
egui does not support multiple languages, you need to download each language font
>>
>>102494888
>unfortunately
*fortunately. i am so glad we're not stuck with something like pre-3.0 clap in std
>>
File: 1553200460251.jpg (51 KB, 500x500)
51 KB
51 KB JPG
>>102429787
Potentially, but it depends on what you're attempting to do. There are some caveats you might run into if you're developing malware that requires access to Windows kernel space to function. At the moment, Rust doesn't offer any first-party support for writing Windows kernel drivers, and instead relies on a third-party crate that doesn't have full coverage of the Windows API. The Rust ecosystem for kernel drivers is still relatively niche, and a lot of the tooling used for debugging/building/profiling drivers is tailored heavily to C/C++, so you'd probably have a better experience starting with that over Rust.
>>
>>102486670
>i was just pretending!
lmao okay MAN
>>
>>102496068
I guess that's a yes, you really need it
>>
why do room temperature left curves keep calling it satire
>>
>>102494842
>>102494888
>Use a crate bro!
let proj_name = input!("Name of project: ");

loop{
let proj_lang = input!("What language do you want to use?: ").to_lowercase();

match proj_lang.trim() {
"c++" | "cpp" => {
// Handle C++ projects
},
"java" => {
// Handle Java projects
},
_ => {
println!("Invalid language. Please choose from C++, Java, etc.");
}
}
}
>>
File: file.png (165 KB, 1178x1042)
165 KB
165 KB PNG
>>102469995
if you're going to UFCS-maxx, you gotta start newlining so you can refactor and read the chains easier
>>
>lisp thread got archived yesterday
>rust thread about to hit bump limit
Very sad.
>>
>>102497029
wouldn't have happened if lispies would stop using memelangs, and just converge on Shen
>>
>>102497269
Redpill me on Shen then.
>>
>>102497326
An actually future forward lisp that isn't delusional.
Do you wish optional type checking wasn't bad?
Wouldn't it be nice if pattern matching had good syntax?
Static types didn't feel bolted on?
Do you like Prolog and the implications of a Sequent Calculus based type system?
https://www.youtube.com/watch?v=lMcRBdSdO_U
https://shenlanguage.org/index.html
>>
>>102497622
Gonna watch that, thanks.
>>
>>102497269
i haven't thought about shen shilling in what feels like 8 years
>>
>>102496314
I'd like to be able to run your-tool --lang=java is the thing
If you don't then that's OK but if you get users they may ask for that sooner or later
>>
File: trans_ferris.jpg (74 KB, 975x975)
74 KB
74 KB JPG
I've always been interested in computers. I tried to learn programming many times throughout my life. I've spent the last year and a half studying and practicing with Rust, and seeing the Code of Conduct and other trans developers giving talks & holding moderator positions on the community Discord is what made me feel like I had a place ^~^

The toxic programming communities online were almost always the reason I quit trying to learn the other times :<
>>
>>102501115
This is an example of what I'm doing. I'm just making an app to template my labview project since the official templating system is dogshit.

All I want to do is build a normal project, drop it in a folder and it officially becomes a template. There is also a .hooks folder in the project to run LabVIEW scripts during the process. A .deps file to store dependencies with a script that will check if these dependencies have been installed and install them when building the project.
>>
>>102493759
>>102489798
>>102493759
>>102489798
I appreciate it. Another Anon recommended that I stay away from this pattern and just add an enum field in the Chunk struct. Would you agree with that over using wrappers?
>>
File: file.png (774 KB, 1345x885)
774 KB
774 KB PNG
>>102442945
these fucking faggots man
>>
>>102503361
>see software used by degenerates
>"WTF WHY IS THE CREATOR OF THIS SOFTWARE A DEGENERATE???"
are you retarded
>>
>>102490054
egui
>>
>>102501322
8/8 b8 m8
>>
File: 1528331606193.png (302 KB, 1393x790)
302 KB
302 KB PNG
fn main() {
println!(
"{}",
(0..3)
.map(|y| (0..15)
.map(|x| ([60590, 17578, 18146][y & 3] & 2 << x > 0)
.then_some("@")
.unwrap_or("`"))
.collect())
.collect::<Vec<String>>()
.join("\n")
);
}
>>
File: NitoriArtwork.png (317 KB, 532x599)
317 KB
317 KB PNG
>>102503815
fn main() {
println!(
"{}",
(0..3)
.map(|y| (0..19)
.map(|x| ([340823, 152913, 152951][y & 3] & 1 << x > 0)
.then_some("@")
.unwrap_or("`"))
.collect())
.collect::<Vec<String>>()
.join("\n")
);
}
>>
File: 1669437886165012.jpg (200 KB, 465x951)
200 KB
200 KB JPG
>>102503951
fn main() {
println!(
"{}",
(0..3)
.map(|y| (0..15)
.map(|x| ([6007, 5457, 30583][y & 3] & 1 << x > 0)
.then_some("@")
.unwrap_or("`"))
.collect())
.collect::<Vec<String>>()
.join("\n")
);
}
>>
>>102504112
fn main() {
println!(
"{}",
(0..73)
.map(|y| (0..87)
.map(|x| ([0x3e7000033e000000_u128,0x61f8ffe7c3000000,0xc1ff001fc1800000,0x81f80003c0800000,0x141f00000e0c00000,0x1c3e0402070c00000,0x387c0402031e00000,0x3878048201be00000,0x3cf0048301be00000,0x7cf0048308cd00000,0x79f80a84884500000,0x51f80a848c6500000,0x51ff928c846100000,0x81fe2188443080000,0x83f84198423080000,0x83d85913423080000,0x103c09923211840000,0x103c08120211840000,0x103c10140219840000,0x103c12181219840000,0x203c3f907f0d820000,0x203c3fc0ff0d820000,0x203c2be1dd0d820000,0x403e2f807d0f820000,0x403e2f807d1f810000,0x403e2f807d1f010000,0x40362700393f010000,0x803130000137008000,0x8031b0000337008000,0x807098120356008000,0x10070540c0556004000,0x20070320019a6004000,0x20060198067c6002000,0x40260007f8f06202000,0x8026001deee02201000,0x8024002e1d002200800,0x10044004a14802100400,0x2004400c9e4c01100200,0x400cc008924401180100,0x800c8019122601180080,0x1000c803d122f01180040,0x20018803ff23f008c0020,0x40018807f123f808c0010,0x4003900fe113fc08c0250,0x80039017e211fe04e0368,0x14003a02fe271ff04e0374,0x1c003205f6411ff82603f4,0x3c80740bf4431bfc2703fe,0x39887415f4410bfe3713fe,0x3988742bec410dfd171bfe,0x3b987837e82205fd1719fe,0x7f987057fc3705fa8f1dff,0x7fb8704bde7f9ef4871dff,0x7fb83044bffffe48861dff,0x7fbc30233fffff71061dff,0x7f9c301c3fffff0e061dff,0x7f9c10001ffffe00041ddf,0x7fcc100001b720000419df,0x7fc4100006401800041b9f,0x7dc6180007e1f8000c339f,0x3ce2080007e1f80008231e,0x3c60080007e1f80008021a,0x3c30040007e1f800100006,0x1e10040007e1f800200004,0x1b08020007e1f80020080c,0x90c030007e1f800601808,0x406018007e1f800602010,0x203006007e1f800c04020,0x181c01007e1f8018080c0,0x60f86007e1f802070300,0x1c2f8007e1f807fa1c00,0x3c0000421080003f000,0x3c0f000000000][y] & 1 << x > 0)
.then_some("@")
.unwrap_or("`"))
.collect())
.collect::<Vec<String>>()
.join("\n")
);
}
>>
>>102504502
sugeeee
>>
>>102503815
>>102503951
>>102504112
>>102504502
ok?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.