234 karma · joined Jan 9, 2019 (7y ago) · 69 submissions
comment 2mo ago · link · parent
if a == b { ...
Just that the check will be replaced at compiletime with a constant, since the borrow-checker tracks all objects lifetimes and can use that information to optimize the check away.
The objects themselves don't make it into the compiled binary, since they have no size, but all the required information about them will make it in. So you can treat them like ordinary objects and do all the usual operations on it, without wasting any memory during runtime.
comment 2mo ago · link · parent
For the times where there is a background load: RTIC has task priorities and pre-emption, so you can run your compute-intensive task with a lower priority and react to interrupts in a timely manner.
comment 6mo ago · link · parent
It's a shellscript that they encrypted. They decrypt it and feed the decrypted output immediately into the shell, to be sourced.
That encrypted secrets file could contain any shellscript, so the aliases are stored in there, together with the API-Keys and passwords.
comment 9mo ago · link · parent
comment 11mo ago · link · parent
comment 1y ago · link · parent
You can also create a struct, put your "global" variable inside it and then put all the functions that need the variable into an Impl block of that struct. If you then add the parameter `&self` to these functions, you can access the "global"variable any time via `self.global_variable`.
If that is not enough, then you can always make an actual global variable by first wrapping it in a Mutex, to prevent simultaneous access and then wrapping that in an Arc for Atomic Reference Counting. That allows you to pass "copies" of that variable around anywhere, satisfying the borrow-checker (since the variable is now reference-counted in a thread-safe way).
If you need a lot of parallel reading, replacing the Mutex with an RwLock is a good idea, since it allows locking from multiple threads, if you want to read it in most cases.
comment 1y ago · link · parent
You can easily write code that does not contain any possible panic points, if you want.
15.
Show HN: A small library for stack-trace-like error messages in Rust(docs.rs ↗)
4 points · by AnyTimeTraveler · 1y ago · discuss
comment 1y ago · link · parent
Anything I missed, that explains this?
comment 1y ago · link · parent
comment 1y ago · link · parent
What about the demolishing of government agencies that DOGE is trying (and sometimes succeding) in? You call it "termination of employees", but don't seem to consider that they tried to fire jugdes who restrained their power. This looks to me like a plain powergrab. I hope I don't need to tell you where something like this leads, but I am certain it's not going to be democratic or respectful of civic freedoms.
As a non-straight non-binary (neither cis-male or -female) person, the US is currently just about the last place I want to be. If the current trend continues, then I genuinely fear for the lives of some of my friends.
comment 1y ago · link · parent
In my masters degree, there was another course, where one built their own computer PCB in Eagle, got it fabbed and then had to make a game for the 8052 CPU on there. 8052 assembly is very fun! The processor has a few bytes of ram where every bit is individually addressable and testable. I built the game Tetris on three attached persistence of vision LED-Matrices[1]. Unfortunately, the repository isn't very clean, but I used expressive variable names, so it should be readable. I did create my own calling convention for performance reasons and calculated how many cpu cycles were available for game logic between screen refreshes. Those were all very fun things to think about :)
Reading assembly now has me look up instruction names here and there, but mostly I can understand what's going on.
[0] https://github.com/AnyTimeTraveler/HardwareNaheProgrammierun... [1] https://github.com/AnyTimeTraveler/HardwarenaheSystementwick...
comment 2y ago · link · parent
Automat's objective is to be able to semi-autonomously play a variety of games. It's the first step towards a more general environment for interacting with computers.
Currently Automat's functionality is limited to keyboard macro recording & playback. It's fairly unstable but if you're lucky and it runs on your machine, it can be useful for automating some basic actions.
comment 2y ago · link · parent
comment 2y ago · link · parent
I am very excited to use this!
My optimal workflow would be, to use code for describing the netlist using components, then use a combination of graphical and code editor to layout the PCB, like how the UI editor in Android studio used to work. (I don't know if it still works this way) I'd love to layout my components using UI like in the CAD program "Onshape", which let's you set your constraints visually and the program visualizes conflicting constraints.
I would love to start working on a project in code and then make an export into KiCAD to make final changes and send it off. Then, as the project gets further along, the point where I would switch to KiCAD would gradually shift further and further towards production. If I see this correctly, you are already aiming for that and I commend you for that approach :)