Post Ak0vofEBgniSTzpZK4 by foone@digipres.club
 (DIR) More posts by foone@digipres.club
 (DIR) Post #AjsVZXSb8SZtLWltjM by foone@digipres.club
       2024-07-13T05:34:46Z
       
       0 likes, 0 repeats
       
       I'm writing rust without fully understanding the language. Pray for me.Actually I guess that's true of most language I program in? Like, I'm sure there's some obscure python syntax or behavior I can't remember, despite calling myself a python programmer and having done it professionally for many years.but my point was more that I barely know any rust. there's entire parts of syntax I don't understand yet. but I'm coding anyway!
       
 (DIR) Post #AjsVkvhZLY2viPCp5E by foone@digipres.club
       2024-07-13T05:35:57Z
       
       0 likes, 0 repeats
       
       I just had to look up why "str" didn't work (I mean "String", a different type entirely)
       
 (DIR) Post #AjsVqwAUWcDWtpbAoK by mctwist@mastodon.acc.umu.se
       2024-07-13T05:37:49Z
       
       0 likes, 0 repeats
       
       @foone Been there done that.
       
 (DIR) Post #AjsVxLE6GvziLzLA3M by whitequark@mastodon.social
       2024-07-13T05:37:55Z
       
       0 likes, 0 repeats
       
       @foone this is most people with most languagesthis is also why Amaranth is like 60% hand-holding
       
 (DIR) Post #AjsW3C3hGqMReqGTjc by A_C_McGregor@topspicy.social
       2024-07-13T05:39:21Z
       
       0 likes, 0 repeats
       
       @foone I used to manage software development. This is entirely normal for programmers. We just don't tell the upper management.
       
 (DIR) Post #AjsWKRkYBUoxFJXIRc by 114N@mastodon.social
       2024-07-13T05:43:21Z
       
       0 likes, 0 repeats
       
       @foone Oh god the rust string situation is admittedly crazy and I say this as a rust programmerLike I get why they need the 6+ different string types but damn they have more than 6 different string types
       
 (DIR) Post #AjsWlYubfCgZHIAZ04 by foone@digipres.club
       2024-07-13T05:48:05Z
       
       0 likes, 0 repeats
       
       @114N and I only know two! So many more string types to learn!
       
 (DIR) Post #AjsYCgfR2O0D6TZTYO by mjfgates@wandering.shop
       2024-07-13T06:04:09Z
       
       0 likes, 0 repeats
       
       @foone If you write it carefully enough, you can create C code that compiles fine as just about anything. So it's all C, right?
       
 (DIR) Post #AjsYsuxMIjuRaC5kxc by foone@digipres.club
       2024-07-13T06:11:48Z
       
       0 likes, 0 repeats
       
       oh you have to define your return types. I didn't know that. I was returning the wrong ones and the compiler was mad
       
 (DIR) Post #AjsYySNRTHZugPvvjk by shinypb@hachyderm.io
       2024-07-13T05:38:48Z
       
       0 likes, 0 repeats
       
       @foone I never got past the “constantly looking stuff up” phase of Rust competency, but I really enjoyed it—something about constructing valid Rust programs feels like Actual Engineering to my brain. I hope you're having fun. ✨
       
 (DIR) Post #AjsZ9EQ1hyYkZsHQVU by foone@digipres.club
       2024-07-13T06:13:38Z
       
       0 likes, 0 repeats
       
       wait is this function returning the Result that Some of it is Ok?
       
 (DIR) Post #AjsZEVAkqVdnzCeLbM by anotherwalther@mastodon.social
       2024-07-13T06:15:31Z
       
       0 likes, 0 repeats
       
       @foone best of luck! the compiler error messages should be really helpful in most cases and nudge you towards the right direction. if you get stuck, i'm sure a lot of people are willing to help - the rust playground is convenient for sharing examples https://play.rust-lang.org/
       
 (DIR) Post #AjsZTMQtccnLDyHk80 by foone@digipres.club
       2024-07-13T06:18:19Z
       
       0 likes, 0 repeats
       
       I'm not entirely sure I am sober enough to understand how Results interact with Options<>Result is an enum that's either Ok or Err, and Option is an enum that's either None or Some. Is it that for Result, there's parameters with both Ok and Err, but with Option, there's no parameters with None? And you just use them differently?
       
 (DIR) Post #AjsZYlSvygTaJIobJY by ospalh@chaos.social
       2024-07-13T06:19:28Z
       
       0 likes, 0 repeats
       
       @foone I recently learned that you *can* give return type hints in Python, too.https://docs.python.org/3/library/typing.html
       
 (DIR) Post #AjsZdgUvsKIgLp60H2 by crashglasshouses@union.place
       2024-07-13T06:19:38Z
       
       0 likes, 0 repeats
       
       @foone i don't think anyone starts learning any language knowing very much. if you started with knowing everything, i think there would no such thing as learning.
       
 (DIR) Post #AjsZjZEDoeoHXh5JOy by ospalh@chaos.social
       2024-07-13T06:21:25Z
       
       0 likes, 0 repeats
       
       @foone Usually they don't interact.You use Options as function parameters and Results as return value.
       
 (DIR) Post #AjsZpDOxsdMpaMnpjs by clementd@framapiaf.org
       2024-07-13T06:22:14Z
       
       0 likes, 0 repeats
       
       @foone Yes. You can use `?` with both, as a short-circuiting operator
       
 (DIR) Post #AjsaKaEb2Rl5NRuW6y by max@mastodon.xolus.net
       2024-07-13T06:28:05Z
       
       0 likes, 0 repeats
       
       @foone yes, Option<T> is isomorphic to Result<T, ()>.One reason for distinguishing them is, for instance, the compiler can warn you if you implicitely drop a result, because that means you didn't properly check for errors.
       
 (DIR) Post #AjsaWZPbvD2wIlmIvw by foone@digipres.club
       2024-07-13T06:30:07Z
       
       0 likes, 0 repeats
       
       I think I understood that but now I'm trying to understand the anyhow crate. you can attach contexts to function calls so that their errors are better commented? I'm missing something here
       
 (DIR) Post #AjsbcX0pr976YEb1Mm by foone@digipres.club
       2024-07-13T06:42:16Z
       
       0 likes, 0 repeats
       
       oh, there's a foo() function returning anyhow::Result, so other code can do foo().with_context("trying to foo")so when the anyhow::Result from foo() gets printed out on the console, it can say something like "Failed: while trying to foo"
       
 (DIR) Post #AjsbkvUwheAqoCgPUe by foone@digipres.club
       2024-07-13T06:43:58Z
       
       0 likes, 0 repeats
       
       and with_context() is anyhow::Result.with_context, and it returns itself. So you can chain it like that.
       
 (DIR) Post #AjscYgGlb4sw3am9CK by Garonenur@rollenspiel.social
       2024-07-13T06:52:44Z
       
       0 likes, 0 repeats
       
       @foone how Else would one learn a new programming language?
       
 (DIR) Post #Ajsd5ttFya5xrDcSYK by cxberger@mastodon.boiler.social
       2024-07-13T06:59:02Z
       
       0 likes, 0 repeats
       
       @foone yep - you'll notice that variables can't be set to null or equivalent, eg let x: u32 = None doesn't work. Option<T> is "maybe there's a T here, maybe it's just None" (and there's no way to treat None as if it were a plain T - the closest you can get is unwrap() and similar, but they will crash the entire thread if it's None)Result<T> has no special relationship to this. Their whole thing is "either the successful result of whatever you tried to do, or an error that resulted from the attempt" (with similar safeties as Option). I guess you could technically implement option as Result<T, ()> but that would be silly and less readable to actually use
       
 (DIR) Post #AjsdTimwu5eoNN1mHQ by cxberger@mastodon.boiler.social
       2024-07-13T07:03:17Z
       
       0 likes, 0 repeats
       
       @foone anyhow::Result in particular is really good about squashing down disparate error types into a single, very "stringly typed" error (you'll notice it only has one type parameter instead of the two that Result<T, E> has). So you lose the ability to effectively reason about what the error is in your application (eg it's hard to tell if a request timed out or if the connection was reset) but you don't have to worry about manually "unifying" all the possible errors that might occur in some complicated function
       
 (DIR) Post #AjsdtmGCcNf6fm8Ray by faassen@fosstodon.org
       2024-07-13T07:07:52Z
       
       0 likes, 0 repeats
       
       @fooneString in Rust is like a string builder that owns the memory of the string. str is a reference to a slice within that (or a constant literal string)That helped me think about it
       
 (DIR) Post #Ajse28W3ku8I0xXQEC by faassen@fosstodon.org
       2024-07-13T07:09:28Z
       
       0 likes, 0 repeats
       
       @fooneYes. There are convenience methods to turn Option into Result and back too. And the ? works as an early return shortcut if Err or None
       
 (DIR) Post #AjsfAHUgMO8A85LENE by teivel@mas.to
       2024-07-13T07:22:02Z
       
       0 likes, 0 repeats
       
       @foone context and with_context should be called wrap_err and wrap_err_with (as they are called in miette which has prettier error messages).They take an error and "wrap" it in another error whose source is the original error, e.g. you can wrap an invalid utf8 error with invalid username to get the error invalid username: string was not utf8.The with variant take a closure/function which generates the error message (in case generating it is expensive i.e. you need to fetch some data)
       
 (DIR) Post #AjsgpbdMU7PGQ4fcHI by foone@digipres.club
       2024-07-13T07:40:44Z
       
       0 likes, 0 repeats
       
       the docs just told me I can manually customize my panic and I have very little understanding as to what that means
       
 (DIR) Post #AjsidVuy6vvd7oGdxQ by abrasive@digipres.club
       2024-07-13T08:00:27Z
       
       0 likes, 0 repeats
       
       @foone if a doctor offered me the chance to customise my panic you best believe I'd be all over that
       
 (DIR) Post #Ajsivhxo40R7hGGpzE by tyalie@chaos.social
       2024-07-13T08:04:04Z
       
       0 likes, 0 repeats
       
       @foone i'm not fully sure which one you meant, but one option is, that there's a general panic routine that runs on all exceptions that aren't caught by you. There you can write your own routines how the error will be handled. Often times people use it to customize the message or on embedded systems to do a basic initialization of UART to print out the error and where it occurred.
       
 (DIR) Post #Ajsj0NNK2RZ7I5QnNg by ospalh@chaos.social
       2024-07-13T08:04:10Z
       
       0 likes, 0 repeats
       
       @foone It means you should look at your copy of the Hitchhikers Guide to the Galaxy for a bit with "'DON'T PANIC' in large, friendly letters on the cover."#HHGG #DontPanic
       
 (DIR) Post #AjskqN2SdOYnGA1w9I by teivel@mas.to
       2024-07-13T08:25:55Z
       
       0 likes, 0 repeats
       
       @foone You can override the function that prints panic messages (see std::panic::update_hook)
       
 (DIR) Post #Ajsyk3t8JyIbUDYMMK by isomer@fosstodon.org
       2024-07-13T11:00:51Z
       
       0 likes, 0 repeats
       
       @foone I find http://tinyurl.com/rust-transform helpful to understand result vs option.H/t David Drysdale
       
 (DIR) Post #AjszXn7ExGRpwkresK by jack@social.jacklinke.com
       2024-07-13T11:10:17Z
       
       0 likes, 0 repeats
       
       @foone Set it to 💯!
       
 (DIR) Post #Ajt0Fo3MpXsFb12bDc by jeremy_list@hachyderm.io
       2024-07-13T11:18:14Z
       
       0 likes, 0 repeats
       
       @foone @114N there's those two types for representing unicode strings as UTF-8 (actually more if you're counting &str separately from ARC<str>, etc), another two types for strings in whatever the host OS uses to represent filenames, a few more for arbitrary sequences of bytes, etc.
       
 (DIR) Post #Ajtp5bHQYruwkNVZTs by ThatHumanBeing@social.vivaldi.net
       2024-07-13T20:47:21Z
       
       0 likes, 0 repeats
       
       @foone
       
 (DIR) Post #Aju0zrN31TKoMcAMzI by foone@digipres.club
       2024-07-13T23:00:30Z
       
       0 likes, 0 repeats
       
       ugh. I slept for like 9 hours and the Rust code is still here
       
 (DIR) Post #Aju18MfiWuP1l7xDkm by foone@digipres.club
       2024-07-13T23:00:39Z
       
       0 likes, 0 repeats
       
       and I still don't understand it
       
 (DIR) Post #Aju18PGItqrBnB5T3g by foone@digipres.club
       2024-07-13T23:01:33Z
       
       0 likes, 0 repeats
       
       anyway the part of the puzzle that I think I inadvertently left out of this thread is that I'm starting out learning rust by modifying an existing rust program, not in writing anything my own.So there's a lot of "how the fuck does this work?" and having to read the source until I figure out what keywords I need to google
       
 (DIR) Post #Aju1Sov9D8AXAAvRqa by foone@digipres.club
       2024-07-13T23:02:04Z
       
       0 likes, 0 repeats
       
       which is a lot easier when it's a word like "Result" or "anyhow with_context" and not "?"
       
 (DIR) Post #Aju1SrXrSAKBIp3OT2 by foone@digipres.club
       2024-07-13T23:02:27Z
       
       0 likes, 0 repeats
       
       (I think I figured out ? now, you don't need to provide any help. that was just an example)
       
 (DIR) Post #Aju1dLcGVM49Si75Zg by foone@digipres.club
       2024-07-13T23:03:17Z
       
       0 likes, 0 repeats
       
       it's working and I am learning rust, it's just very much the same vibes as learning to swim by having your grandpa fling you into the deep end
       
 (DIR) Post #Aju1mDSMDCwOlFhwUS by foone@digipres.club
       2024-07-13T23:09:02Z
       
       0 likes, 0 repeats
       
       @immibis to be honest I'm over here on mastodon trying to figure out rust because my normal social media (tumblr) is just people talking about shooting trump
       
 (DIR) Post #Aju1rIDLwv6exw6uKu by foone@digipres.club
       2024-07-13T23:09:17Z
       
       0 likes, 0 repeats
       
       I should probably figure out what these & symbols mean
       
 (DIR) Post #Aju2A9I3LySun2IfSa by foone@digipres.club
       2024-07-13T23:14:33Z
       
       0 likes, 1 repeats
       
       is there any ide that's recommended for doing rust? I'm currently just using Sublime Text which has some syntax highlighting but not much else. Is there good support in VS.code or something?
       
 (DIR) Post #Aju2NCIjTChbtPq8Ku by vurpo@mastodon.coffee
       2024-07-13T23:14:51Z
       
       0 likes, 0 repeats
       
       @foone it means you have this object AND something else too, as a little treat(joke)
       
 (DIR) Post #Aju2TJdl61iUONamEC by maco@wandering.shop
       2024-07-13T23:15:42Z
       
       0 likes, 0 repeats
       
       @foone vscode is what everyone i work with is using for rust. it has plugins.
       
 (DIR) Post #Aju2jS9ZDFLJQcAIds by polpo@bitbang.social
       2024-07-13T23:18:01Z
       
       0 likes, 0 repeats
       
       @foone most of the rustaceans where I work use VSCode
       
 (DIR) Post #Aju2kor4II3E7rAE6q by forst@mastodon.social
       2024-07-13T23:18:19Z
       
       0 likes, 0 repeats
       
       @foone Not a Rust dev/haven't tried, but JetBrains have RustRover: https://www.jetbrains.com/rust/
       
 (DIR) Post #Aju2s8v064xINWUmGm by foone@digipres.club
       2024-07-13T23:17:57Z
       
       0 likes, 0 repeats
       
       oh now now I have to understand how implementing iterators works
       
 (DIR) Post #Aju2zGOKi7S9aCbviS by kc@mastodon.dragoncave.dev
       2024-07-13T23:18:32Z
       
       0 likes, 0 repeats
       
       @foone yeah vscode with rust-analyzer is pretty goodI know there are rust-analyzer plugins for other code editors (like nvim, emacs) but I'm not sure how good they are
       
 (DIR) Post #Aju3DEK1CaZ1DbFiDo by bnut@aus.social
       2024-07-13T23:18:49Z
       
       0 likes, 0 repeats
       
       @foone I use VSCode it’s pretty good, I recommend the rust-analyzer extension. It’s a the most popular LSP integration I believe, and is more featureful (maybe taken over as official). Basically any IDE that has good LSP support should be the same with rust-analyzer I think. (LSP=language server protocol, a way to share language integrations between IDEs).
       
 (DIR) Post #Aju3EJeCt3WU1cDHUW by ubik@fedi.turbofish.cc
       2024-07-13T23:18:37Z
       
       0 likes, 0 repeats
       
       @foone VScode + rust-analyzer
       
 (DIR) Post #Aju3S4Xdqa6pEGhaBU by foone@digipres.club
       2024-07-13T23:19:13Z
       
       0 likes, 0 repeats
       
       okay apparently the problem is that this code implements iterator for "foobar", but not for "&foobar"I'm not sure what the fuck that means
       
 (DIR) Post #Aju3S7OXEtbi4tSquG by foone@digipres.club
       2024-07-13T23:20:10Z
       
       0 likes, 0 repeats
       
       but I do like that it's "for more information, run "rustc --explain E0277"I grew up on the TRS-80 which just gave you ?ER when something was wrong. What, specifically, was wrong? Fuck you, that's what.
       
 (DIR) Post #Aju3S8lc8Zf8KlGnWC by foone@digipres.club
       2024-07-13T23:23:59Z
       
       0 likes, 0 repeats
       
       if you look closely you can spot where the article is supposed to be
       
 (DIR) Post #Aju3gkvt2ED0kz2nJY by xyrill@digitalcourage.social
       2024-07-13T23:19:59Z
       
       0 likes, 0 repeats
       
       @foone Anything where you can set up rust-analyzer as your language server. I’m on vim with ALE.
       
 (DIR) Post #Aju3pX2Q42faGmHh1U by leo@60228.dev
       2024-07-13T23:20:04Z
       
       0 likes, 0 repeats
       
       @foone vscode is the best supported but i hate vscode. for a while i just used vim but i tried jetbrains rustrover recently and i like it
       
 (DIR) Post #Aju4ESu2ZkZcgUFpbM by TheIdOfAlan@hachyderm.io
       2024-07-13T23:20:48Z
       
       0 likes, 0 repeats
       
       @foone I use Rust Analyzer with Neovim. It can be used with VS Code as well. It's not exactly debugging, but it gives lots of info and type details and help with certain types of errors.https://rust-analyzer.github.io/and it looks like it works with sublime text too:https://rust-analyzer.github.io/manual.html#sublime-text
       
 (DIR) Post #Aju4TOk0tDJXG2dI8W by jaxter184@social.linux.pizza
       2024-07-13T23:21:34Z
       
       0 likes, 0 repeats
       
       @foone i use kakoune and hoping to switch to helix soon, but if you're on Windows, VSCode is probably the way to go.
       
 (DIR) Post #Aju4ckk4SZzC6B7Wka by tom_armstrong@mastodon.cloud
       2024-07-13T23:22:13Z
       
       0 likes, 0 repeats
       
       @foone I don’t write Rust, but AFAIK, Zed is written in Rust and is used by their dev team to work *on* Zed, so maybe that?
       
 (DIR) Post #Aju4obnhWuc7qHTIx6 by clayote@peoplemaking.games
       2024-07-13T23:24:06Z
       
       0 likes, 0 repeats
       
       @foone I think basically & is the same as in c and c++ but you have to use it more, because of move semantics. If you pass the raw var into a function you'll lose it
       
 (DIR) Post #Aju55F2ZPA6sAxMElc by dngrs@chaos.social
       2024-07-13T23:25:36Z
       
       0 likes, 0 repeats
       
       @foone if VSCode is too sluggish for you but you want a GUI, try Lapce. Builtin Rust support (though last time I used it it was somewhat unintuitive to turn on), *extremely* fast in comparison, open source.https://lapce.dev/
       
 (DIR) Post #Aju56SHjeBnvXi1uJk by mhoye@mastodon.social
       2024-07-13T23:25:19Z
       
       0 likes, 0 repeats
       
       @foone I would sometimes like to be able to turn on something like “student’s syntax highlighting” in a language I don’t know, that simply explains the operator or form I’m mousing over to me like it would to somebody who doesn’t know the basics yet.
       
 (DIR) Post #Aju5ELkhosX7bALRrc by foone@digipres.club
       2024-07-13T23:25:44Z
       
       0 likes, 0 repeats
       
       @slonk I'm modifying someone else's code to parse a language I defined into something that parses more of the language and outputs a different format as output.
       
 (DIR) Post #Aju5O97A6PLWn6oqOm by foone@digipres.club
       2024-07-13T23:26:32Z
       
       0 likes, 0 repeats
       
       @mhoye yeah, that'd be great! like a quick way to say "explain this like I'm 5", pretend I don't know this language and explain what the fuck is going on. You're a compiler, you should know!
       
 (DIR) Post #Aju5XdEbUCg6oSp5dI by Jhynjhiruu@toot.wales
       2024-07-13T23:27:10Z
       
       0 likes, 0 repeats
       
       @foone much wailing and gnashing of teeth, generally
       
 (DIR) Post #Aju5mqp3FV9BIa80rg by dngrs@chaos.social
       2024-07-13T23:29:02Z
       
       0 likes, 0 repeats
       
       @foone (unsolicited advice, though from someone who did give a lot of Rust trainings) learning Rust just from an existing codebase is going to be a lot rougher than other languages. The official book is a great intro, I especially like the interactive version that comes with quiz questions!https://rust-book.cs.brown.edu/
       
 (DIR) Post #Aju5vRLjKHOMtzVcf2 by foone@digipres.club
       2024-07-13T23:29:23Z
       
       0 likes, 0 repeats
       
       type Item = &'a str;this is valid syntax and not someone sneezing into a keyboard?
       
 (DIR) Post #Aju5vTyRZJY12ddZHU by foone@digipres.club
       2024-07-13T23:32:30Z
       
       0 likes, 0 repeats
       
       okay I think the problem is something like: this code originally implemented IntoIterator which was fine because it was backed by a std::vec so it could just use that iterator.but now it's not a std::vec so it doesn't work.except it still kinda is. so... it doesn't work
       
 (DIR) Post #Aju5vVOMIRs5RIlmJU by foone@digipres.club
       2024-07-13T23:45:19Z
       
       0 likes, 0 repeats
       
       now I gotta figure out what a tuple struct is.it seems to be a regular struct except your fields don't have names?
       
 (DIR) Post #Aju5vWnD5XLPmfP8gi by foone@digipres.club
       2024-07-13T23:51:46Z
       
       0 likes, 0 repeats
       
       sometimes I worry I'm not awake & sober enough to understand this. sometimes I worry I've never been that awake and sober. I don't know if I've ever been so knurd I could actually understand this
       
 (DIR) Post #Aju62Lttz12K1umxLU by Jhynjhiruu@toot.wales
       2024-07-13T23:31:42Z
       
       0 likes, 0 repeats
       
       @foone https://doc.rust-lang.org/stable/std/iter/index.html#implementing-iteratorUse the standard library documentation where you can; it's great. https://docs.rs/std/ is a shortcut to it.
       
 (DIR) Post #Aju6IMAsjU31VqMWXI by StompyRobot@mastodon.gamedev.place
       2024-07-13T23:32:55Z
       
       0 likes, 0 repeats
       
       @foone if you have done C#, & in rust is similar to "ref" arguments. Or, in C++, references.Except because of ownership, references are a bigger deal in rust
       
 (DIR) Post #Aju6YdY9tnCI2E0rOy by foone@digipres.club
       2024-07-13T23:36:56Z
       
       0 likes, 0 repeats
       
       @Jhynjhiruu yeah I'm heavily using the official docs and rust by example, I was just searching in the hopes someone had explained my specific issue
       
 (DIR) Post #Aju6cSk41aXdfmPDMW by Tathar@dragonchat.org
       2024-07-13T23:37:55Z
       
       0 likes, 0 repeats
       
       @foone This is the point where I either hope F9 clears all that away or I just hit the back button.
       
 (DIR) Post #Aju6lMaaGownCEDRDs by mousefriend@this.mouse.rocks
       2024-07-13T23:38:06Z
       
       0 likes, 0 repeats
       
       @foone "Be part of a better internet" while being exactly what is wrong with the internet sure is one hell of an irony.
       
 (DIR) Post #Aju6y6DATPcYANKtP6 by tedmielczarek@mastodon.social
       2024-07-13T23:41:37Z
       
       0 likes, 0 repeats
       
       @foone yeah boy that's a tricky one. A few months ago I remember trying to Google Go type assertions without knowing what they were called and having a bad time. (For reference, they look like this: t := i.(T) )
       
 (DIR) Post #Aju7P9UWO2wi9pLvmK by onelson@mastodon.social
       2024-07-13T23:50:30Z
       
       0 likes, 0 repeats
       
       @foone fwiw I also use Sublime but I use a combination of RustEnhanced (for basic syntax highlighting) and the rust-analyzer LSP package for the rest.
       
 (DIR) Post #Aju7WAawgLYPbihhgW by foone@digipres.club
       2024-07-13T23:50:28Z
       
       0 likes, 0 repeats
       
       @kevin yeah see that's the thing: I know enough vaguely similar languages that I could definitely read the book and thus learn rust.I am specifically choosing not to do that, and instead trying to dive directly into a complete rewrite of some rust code without any rust knowledge, and only learning rust when it forces me to. This is working to teach me rust, sure, but slowly and confusingly
       
 (DIR) Post #Aju7eWj0HrmoYiSSA4 by foone@digipres.club
       2024-07-13T23:50:56Z
       
       0 likes, 0 repeats
       
       @onelson ooh, handy. I'll have to look into that. Thanks!
       
 (DIR) Post #Aju7uWFBqJMphW8ePo by allwelikeworms@mastodon.social
       2024-07-13T23:54:02Z
       
       0 likes, 0 repeats
       
       @foone HAHAH strings in Rust?  I don't know much about it either, but yeah, I've read rust strings are like ... There's like 6 different types of strings?  Ridonkulous!
       
 (DIR) Post #Aju84X2Dl0yr37qYuu by onelson@mastodon.social
       2024-07-13T23:57:17Z
       
       0 likes, 0 repeats
       
       @foone this is what my cat types in the buffer while walking across my desk.
       
 (DIR) Post #Aju8DGEJbh6jXIfMNU by gregly@retro.pizza
       2024-07-14T00:02:19Z
       
       0 likes, 0 repeats
       
       @foone I’ve joked before that Rust’s use of ‘a makes it look like Klingon to me 😅
       
 (DIR) Post #Aju8JXWAFBWQtJ0bho by foone@digipres.club
       2024-07-14T00:02:41Z
       
       0 likes, 0 repeats
       
       and someone mentioned cargo-mommy to me and now I'm having my brain broken by that.PROGRAMMING IS HARD ENOUGH ALREADY WHY DID YOU HAVE TO GO AND MAKE IT HORNY?
       
 (DIR) Post #Aju8Oi6OJqdfAKQ3bE by canteen@cijber.social
       2024-07-14T00:04:29Z
       
       0 likes, 0 repeats
       
       @foone isn't a tuple just an immutable list?
       
 (DIR) Post #Aju8X6iIhLwBoU9fsm by foone@digipres.club
       2024-07-14T00:11:13Z
       
       0 likes, 0 repeats
       
       @gregly I should install a klingon module so instead of compile-success I get "qa'pla!" and when my code doesn't compile it calls me a petaQ
       
 (DIR) Post #Aju8kPJKrhAVFxot0a by foone@digipres.club
       2024-07-14T00:14:59Z
       
       0 likes, 0 repeats
       
       @canteen in python, sure. I think it's pretty similar in rust, but there's also tuple-structs which don't seem to be all that related to tuples
       
 (DIR) Post #Aju8qJNDqvkSa0S9se by onelson@mastodon.social
       2024-07-14T00:17:35Z
       
       0 likes, 0 repeats
       
       @foone when people are recommending vscode for rust dev, it's really a transitive property of the fact the support comes from rust-analyzer.
       
 (DIR) Post #Aju9DUySt6NZDdvgw4 by eichin@mastodon.mit.edu
       2024-07-14T00:24:12Z
       
       0 likes, 0 repeats
       
       @foone BITD we had "cdecl" for translating things like that from C to words ( https://cdecl.org/ based on the 1996 port *to* linux of the commandline tool) and I wonder if there's a similar "explainer" for rust syntax.
       
 (DIR) Post #Aju9ITMYJ4effXZHF2 by ellenor2000@mastodon.top
       2024-07-14T00:26:05Z
       
       0 likes, 0 repeats
       
       @foone programming languages are always second languages
       
 (DIR) Post #Aju9NDeo7vwmPIN0Vs by mjk@hachyderm.io
       2024-07-14T00:31:02Z
       
       0 likes, 0 repeats
       
       @foone big mood
       
 (DIR) Post #Aju9cwoQWVyAnTMxN2 by foone@digipres.club
       2024-07-14T00:34:50Z
       
       0 likes, 0 repeats
       
       okay, enough people being horny about programming languages and shooting at former presidents. this code still can't iterate
       
 (DIR) Post #Aju9f9Oyge12QDW4Dw by Jhynjhiruu@toot.wales
       2024-07-14T00:33:40Z
       
       0 likes, 0 repeats
       
       @foone you get used to lifetime syntax after a while, but it's definitely one of my least liked bits of Rust
       
 (DIR) Post #Aju9mXyFjqMseFXhnE by foone@digipres.club
       2024-07-14T00:36:54Z
       
       0 likes, 0 repeats
       
       so (and I'm writing this primarily to rubber-duck my own understanding of it, rather than specifically asking questions, though feel free to speak up if you think you can help):I have a tuple struct called "Commands" that contains an std::vec of "Command" structs. I'm passing this into a function, as a reference. so the function gets a &Commands parameters.It then tries to do "for command in commands" to iterate through the contents of the Commands struct, but it can't.
       
 (DIR) Post #Aju9malbLL1xJse8zQ by foone@digipres.club
       2024-07-14T00:37:50Z
       
       0 likes, 0 repeats
       
       originally this code had the  IntoIterator trait implemented, but that doesn't work. Because (I'm reasonably sure) we don't have a Commands, we have a &Commands.
       
 (DIR) Post #AjuAAIXal5Gxk7OiEy by foone@digipres.club
       2024-07-14T00:38:30Z
       
       0 likes, 0 repeats
       
       because defining an iterator (or IntoIterator) for Commands is different than defining one for &Commands
       
 (DIR) Post #AjuAALRJyr2UjXUFNo by foone@digipres.club
       2024-07-14T00:39:02Z
       
       0 likes, 0 repeats
       
       so... presumably I need to implement an iterator/IntoIterator for &Commands.Not really sure how to do that, but I can hopefully figure it out
       
 (DIR) Post #AjuAPE9rKsVAUfPpoG by Taco_lad@aus.social
       2024-07-14T00:39:10Z
       
       0 likes, 0 repeats
       
       @foone 'can't even iterate bro'
       
 (DIR) Post #AjuAdKViVvIkFYMdDk by wikicliff@fosstodon.org
       2024-07-14T00:43:09Z
       
       0 likes, 0 repeats
       
       @foone I think sometimes the *compiler* must be thinking "I have no idea what the fuck is going on with this so called code." 😜
       
 (DIR) Post #AjuAmahbgNsB4eLERc by Jhynjhiruu@toot.wales
       2024-07-14T00:45:50Z
       
       0 likes, 0 repeats
       
       @foone well, if it's the Vec<Command> you want to iterate over, you could impl IntoIterator to just pass through the Vec's
       
 (DIR) Post #AjuAvMIwaBNd1gzDWq by 114N@mastodon.social
       2024-07-14T00:46:37Z
       
       0 likes, 0 repeats
       
       @foone So fields in a tuple struct *do* have names, those names are just indices into the structSo if you have a `struct Command(String)` you can access that field using `my_command.0`
       
 (DIR) Post #AjuB5zjIr720CHO4bg by nabijaczleweli@101010.pl
       2024-07-14T00:52:03Z
       
       0 likes, 0 repeats
       
       @foone its entirely probable you could do exactly what you wrote and impl IntoIterator for &Commands, after tossing <'a> and 'a in of course
       
 (DIR) Post #AjuBBZYH65nSkGt9SC by foone@digipres.club
       2024-07-14T00:52:22Z
       
       0 likes, 0 repeats
       
       "in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type"that error makes sense. I just don't know how to do that
       
 (DIR) Post #AjuBL2XWgqz1Fw3LHc by nabijaczleweli@101010.pl
       2024-07-14T00:56:52Z
       
       0 likes, 0 repeats
       
       @foone I'm guessing you want to write "impl<'a> IntoIterator for &'a Commands {" heer
       
 (DIR) Post #AjuC80NvUTF4lKuXp2 by tedmielczarek@mastodon.social
       2024-07-14T01:05:16Z
       
       0 likes, 0 repeats
       
       @foone just call .iter() on the Vec: for command in commands.iter()
       
 (DIR) Post #AjuCjL0ZmB63RIn5KS by bnut@aus.social
       2024-07-14T01:10:03Z
       
       0 likes, 0 repeats
       
       @foone so a trait like `Iterator` has an associated type `Item`, which would look like `type Item<‘a>;` if it had lifetime parameters, but it doesn’t, so instead you need to put the lifetime on the type you're implementing iterator for so in `impl Iterator for A` it's the `A` bit that needs the lifetime. This is roughly because the implementation needs to have all the generic stuff (like lifetimes) constrained by the type or trait to be unambiguous.So it'd be something like:```impl<‘a> Iterator for MyIterator<‘a> {    type Item = &'a Thing;    fn next(&mut self) -> Self::Item { … }}```for type:```struct MyIterator<‘a> {   my_collection: &’a MyCollection,   state_for_where_your_itererator_at: State,}```Note, you don't necessarily need an `IntoIterator` trait implementation, it's often harder to do with lifetimes, if you can have your own `fn iter(&self) -> MyIterator` method, then you can just implement `MyIterator`.
       
 (DIR) Post #AjuCuN46T8L50JhYn2 by foone@digipres.club
       2024-07-14T01:12:52Z
       
       0 likes, 0 repeats
       
       @tedmielczarek yeah that might be the way to go. it isn't as "elegant" but it does solve my problem
       
 (DIR) Post #AjuE6aSIbsWjxjPLma by smn@l3ib.org
       2024-07-14T01:28:03Z
       
       0 likes, 0 repeats
       
       @foone rust learner pro-tip: every time you get stuck on this crap just use clone() and pass by copy. You'll get a working program sooner, without having to learn the hardest parts of the language. You can come back later and optimize, depending on desire/necessity
       
 (DIR) Post #AjuEsxVWCs3VMAylfM by passcod@mastodon.social
       2024-07-14T01:36:42Z
       
       0 likes, 0 repeats
       
       @foone that pattern (tuple struct with a single field that behaves similarly to the inner type but with stuff added) is called "newtype" btw, in case that helps looking up stuff
       
 (DIR) Post #AjuHksQHWhIH8KMqUS by foone@digipres.club
       2024-07-14T02:09:04Z
       
       0 likes, 0 repeats
       
       I didn't figure that out. I instead just explicitly called iter() on the reference which I defined to call iter() on the std::vec. So now i'm on to other, weirder problems
       
 (DIR) Post #AjuHwz4ccpCPEd0eUi by tedmielczarek@mastodon.social
       2024-07-14T02:11:17Z
       
       0 likes, 0 repeats
       
       @foone ok so the why is that IntoIterator takes a thing and turns it into an iterator. You need to own the thing to do that. You have &Thing which means you're borrowing it, so you can't do that. iter() I stead gives you an iterator of &Item, so you're borrowing each item in the Vec instead.
       
 (DIR) Post #AjuI8kHFSnSSotWWsy by foone@digipres.club
       2024-07-14T02:13:35Z
       
       0 likes, 0 repeats
       
       now I'm trying to figure out the following:I have a vector of Commands (which is an enum). Some of them are Include commands. I need to go through the vec and replace the Include commands with the Commands from the item they're supposed to Include.So I need to iterate through the vec and do something special when the command is an Include vs something else.
       
 (DIR) Post #AjuIGkQGo3OBaVYjoG by foone@digipres.club
       2024-07-14T02:14:15Z
       
       0 likes, 0 repeats
       
       which sounds like a match but I need to run a block of procedural code in response to it being an Include, not just return a value
       
 (DIR) Post #AjuIS0SXWTwaVfzPFo by foone@digipres.club
       2024-07-14T02:15:18Z
       
       0 likes, 0 repeats
       
       so I need something like:for command in commands.iter(){  if type(command) == Include {     //do some stuff here    }}but I don't know the syntax for "if this enum is this type" or if this is a remotely reasonable pattern for rust code
       
 (DIR) Post #AjuIZUFTALBovVRWIi by foone@digipres.club
       2024-07-14T02:16:23Z
       
       0 likes, 0 repeats
       
       ahh there's a matches! macro
       
 (DIR) Post #AjuJ4SzFuEe1zVdCEK by leean00@discuss.systems
       2024-07-14T02:20:29Z
       
       0 likes, 0 repeats
       
       @foone um, are there hashmaps in rust?  Or are those too immutable for that language?
       
 (DIR) Post #AjuJBZIGr9INZtuaxM by nil@furry.engineer
       2024-07-14T02:23:05Z
       
       0 likes, 0 repeats
       
       @foone there's also the "if-let" statement
       
 (DIR) Post #AjuJNJT5WMVryGZVtA by cibyr@omg.wtf.sh
       2024-07-14T02:25:52Z
       
       0 likes, 0 repeats
       
       @foone if let
       
 (DIR) Post #AjuJOLx5lsXbxr6NXc by foone@digipres.club
       2024-07-14T02:25:52Z
       
       0 likes, 0 repeats
       
       @leean00 There are! I don't think they'd be useful here, as the ordering of the Commands is important
       
 (DIR) Post #AjuJh7hkxzu1HMsZF2 by foone@digipres.club
       2024-07-14T02:29:17Z
       
       0 likes, 0 repeats
       
       @Gaelan righto, if let is definitely cleaner for what I need. thanks!
       
 (DIR) Post #AjuK8WFpne5FElsl6G by lily@glaceon.social
       2024-07-14T02:32:06Z
       
       0 likes, 0 repeats
       
       @fooneOption is for nullable values, Result is for fallible operationsErr contains a value so it can tell you why the operation failed.
       
 (DIR) Post #AjuKTaAgQpxvSzW5OC by lily@glaceon.social
       2024-07-14T02:33:39Z
       
       0 likes, 0 repeats
       
       @foonethey're called "references"they're kinda like smart pointers
       
 (DIR) Post #AjuKiib1OINPwJ3MfY by foone@digipres.club
       2024-07-14T02:34:57Z
       
       0 likes, 0 repeats
       
       and if-let.I'm clone()ing everything these days. I'll make this more performant and efficient later
       
 (DIR) Post #AjuM7Z1QDyZbRIoTJ2 by foone@digipres.club
       2024-07-14T02:43:04Z
       
       0 likes, 0 repeats
       
       oh no, I'm borrowing a moved value! I'm not really sure what that means or why it's a problem
       
 (DIR) Post #AjuM7bd4WxsVWeRZGi by foone@digipres.club
       2024-07-14T02:49:14Z
       
       0 likes, 0 repeats
       
       okay my code for the Include nonsense is actually working now.I have .clone() in 90 places and probably only need it in one or twoI shall try to fix this later
       
 (DIR) Post #AjuMvlZjpD7Qqunoqe by shanecelis@mastodon.gamedev.place
       2024-07-14T03:06:39Z
       
       0 likes, 0 repeats
       
       @foone it’s just good prototyping, innit?
       
 (DIR) Post #AjuO4P2B6OnFVCmrdQ by ClarusPlusPlus@peoplemaking.games
       2024-07-14T03:19:12Z
       
       0 likes, 0 repeats
       
       @foone Writing in a language without fully understanding it is how I first transitioned into C++. I ported my game engine code from FreeBASIC to C++, file-by-file, googling furiously as I went.
       
 (DIR) Post #AjuOGXVbQ59hGEKyu0 by StompyRobot@mastodon.gamedev.place
       2024-07-14T03:19:29Z
       
       0 likes, 0 repeats
       
       @foone Typically you'll build a new vec, rather than mutating the original
       
 (DIR) Post #AjuOQ2bfAUycJahdce by technobaboo@ordinary.cafe
       2024-07-14T03:21:21Z
       
       0 likes, 0 repeats
       
       @foone afaik the rust compiler optimizes out unnecessary clones so just run it through clippy and if it doesn't warn you then it's all good
       
 (DIR) Post #AjuOgPt8NJ2z9hgQGu by foone@digipres.club
       2024-07-14T03:26:22Z
       
       0 likes, 0 repeats
       
       @StompyRobot right, that's what I did.
       
 (DIR) Post #AjuOpl6ypv9daJc9js by foone@digipres.club
       2024-07-14T03:26:47Z
       
       0 likes, 0 repeats
       
       @LionsPhil not yet. my allergies are complicated
       
 (DIR) Post #AjuP8jZKnQasInvPCi by shanecelis@mastodon.gamedev.place
       2024-07-14T03:27:32Z
       
       0 likes, 0 repeats
       
       @foone Yes, yes, yes!
       
 (DIR) Post #AjuPBoDHz7RrZk4zrM by foone@digipres.club
       2024-07-14T03:27:36Z
       
       0 likes, 0 repeats
       
       @technobaboo good to know! I don't know what clippy is but I can probably find out
       
 (DIR) Post #AjuPJdrSMEkzmlbQIq by foone@digipres.club
       2024-07-14T03:31:17Z
       
       0 likes, 0 repeats
       
       this code currently generates SVG files. I don't really want to look up how to make it do that better, and I don't need that ability, so now I gotta figure out what to do next. I think I might implement a generate-to-text feature to debug/implement everything before I try generate-to-bytecode? I don't want to have to observe my results in a hex editor
       
 (DIR) Post #AjuPSSYZkzfjKbyZJg by deedeeque@techhub.social
       2024-07-14T03:35:37Z
       
       0 likes, 0 repeats
       
       @foone Borrowing a moved value? How could you!
       
 (DIR) Post #AjuQ3WNMWK8LtIP3se by technobaboo@ordinary.cafe
       2024-07-14T03:41:54Z
       
       0 likes, 0 repeats
       
       @foone it's the rust linter, ties into rustfmt and all so you can specify exactly how you want your code to lint inline and it can even fix most non-idiomatic things for you! might help you learn rust idomatics
       
 (DIR) Post #AjuTZjA0p39MffCvrs by foone@digipres.club
       2024-07-14T04:21:39Z
       
       0 likes, 0 repeats
       
       @technobaboo thanks!
       
 (DIR) Post #AjuVLbmVf1W1dhbrcG by foone@digipres.club
       2024-07-14T04:41:13Z
       
       0 likes, 0 repeats
       
       I'm having to touch parsing code.it hurts but I'm managing
       
 (DIR) Post #AjuVTQVFTet2ycGQXw by foone@digipres.club
       2024-07-14T04:41:28Z
       
       0 likes, 0 repeats
       
       I wonder if I can compile rust code for DOS
       
 (DIR) Post #AjuVZRZkP17E2aEmqO by foone@digipres.club
       2024-07-14T04:44:03Z
       
       0 likes, 0 repeats
       
       OH GOD NO NOT THE BRAZILIAN FLAGthe complexity of the Brazilian flag is half the reason I'm learning Rust!
       
 (DIR) Post #AjuWKl5jf0RMB8lFPE by misty@digipres.club
       2024-07-14T04:52:07Z
       
       0 likes, 0 repeats
       
       @foone Zed has excellent builtin support; it’s what I’ve been using.
       
 (DIR) Post #AjuXiPdhAeiKY9ULYG by foone@digipres.club
       2024-07-14T05:07:43Z
       
       0 likes, 0 repeats
       
       ok as I try to figure out how the parser works, I discover that I haven't properly implemented includes.because right now this is resolving includes after parsing, but variables are resolved during parsing, but you should be able to include a flag for its variables.
       
 (DIR) Post #AjuXsN0NoqTNHBqg4m by foone@digipres.club
       2024-07-14T05:08:05Z
       
       0 likes, 0 repeats
       
       so I'm going to have to somehow move the include handling into the parser, not after it. Nasty.
       
 (DIR) Post #AjuaHdWbjgoXew6556 by foone@digipres.club
       2024-07-14T05:36:33Z
       
       0 likes, 0 repeats
       
       anyway right now I'm trying to figure out parsing variable declarations. There's existing code that handles some basic versions of it, but the problem I'm currently facing is that there are multiple types of values in variable declarations. like:$foo=42$bar="hello"$center=(320,240)$background=RGB(255,0,255)and I have nom-parsers that can handle parsing integers and strings and points and colors, but now I need to handle "it could be any of them"
       
 (DIR) Post #AjuaOnFxx7Jrrtj3mi by foone@digipres.club
       2024-07-14T05:37:26Z
       
       0 likes, 0 repeats
       
       and I've got an enumeration that can be any of them but I'm not sure how to tell nom about this. I can't do alt(integer, string, point, color) because each of those functions returns a different type
       
 (DIR) Post #AjuaU8jVWyclvN5pHk by Nentuaby@wandering.shop
       2024-07-14T05:37:46Z
       
       0 likes, 0 repeats
       
       @foone Yes*!https://github.com/Serentty/rusty-dos* There's a couple technical limitations and it currently requires at least a 386
       
 (DIR) Post #Ajubc5tk3SmRP2Ejrc by foone@digipres.club
       2024-07-14T05:51:29Z
       
       0 likes, 0 repeats
       
       I solved it by writing wrapper functions that are basically identical. there is probably a way to make this more reasonable using generics or a single function with a match, but for now... it's inelegant but presumably at least functional
       
 (DIR) Post #Ajubsj2wGnjtS7T8q0 by phako@chaos.social
       2024-07-14T05:54:43Z
       
       0 likes, 0 repeats
       
       @foone the rust support in vscode is quite nice indeed
       
 (DIR) Post #AjudH07UXifBJDjo3s by chriscoreline@todon.nl
       2024-07-14T06:10:02Z
       
       0 likes, 0 repeats
       
       @foone foone-tier post tbh,
       
 (DIR) Post #AjuezH7emwrcjnUTbM by cr1901@mastodon.social
       2024-07-14T06:29:15Z
       
       0 likes, 0 repeats
       
       @foone Yes and no. Tavy linked one example. But good luck getting upstream to care about explicit multiple address spaces. They don't even want to support it for WASM (which would actually make me care about WASM lmao).(Note: LLVM _does_ support multiple address spaces. E.g. AVR requires it.)I've heard various opinions about the feasibility of supporting multiple address spaces in Rust. Some think it's relatively simple, others think it requires horrifically complex dependent types.
       
 (DIR) Post #Ajuf9Pfjr7Gy9MGYue by comfy@sakurajima.moe
       2024-07-14T06:30:41Z
       
       0 likes, 0 repeats
       
       @foone it compiles to the 3ds, I would be surprised if it didn't
       
 (DIR) Post #AjufHUYdZkHHcPnSts by foone@digipres.club
       2024-07-14T06:30:52Z
       
       0 likes, 0 repeats
       
       handling errors and types are the two main complexities of rust that I've run into so farI'm currently trying to handle the type of errors, so I'm completely screwed
       
 (DIR) Post #AjufiNGWnNIIoz92bw by lambda@chaosfurs.social
       2024-07-14T06:37:48Z
       
       0 likes, 0 repeats
       
       @foone I usually do something along the lines of:alt((map(integer, Value::Integer), map(string, Value::String), map(point, Value::Point), map(color, Value::Color)))Where Value is an enum, each variant being a 1-tuple of the respective type
       
 (DIR) Post #AjugPBuKtq6630BJ7w by syn@ohai.social
       2024-07-14T06:44:49Z
       
       0 likes, 0 repeats
       
       @foone damn I was this close to finding out about that from this toot 🤏🏻
       
 (DIR) Post #AjuiGzfihwdVgsZ1BA by retroswim@bitbang.social
       2024-07-14T07:06:13Z
       
       0 likes, 0 repeats
       
       @foone Could be worse."On Error Resume Next" worse.🙃
       
 (DIR) Post #AjukXLGmNLGJDToyRc by teivel@mas.to
       2024-07-14T07:31:40Z
       
       0 likes, 0 repeats
       
       @foone The rust-analyzer team officially supports VScode. Besides that there is Rust Rover from IntelliJ but I don't know how good their LSP is
       
 (DIR) Post #AjulOCj6rw3m4JHN44 by felurx@troet.cafe
       2024-07-14T07:41:13Z
       
       0 likes, 0 repeats
       
       @foone rust-analyzer is pretty good, so anything that does LSP should be good, I think
       
 (DIR) Post #AjuqeKQoUPnKMwEGmm by thorsummoner@ibite.lol
       2024-07-14T08:40:06Z
       
       0 likes, 0 repeats
       
       @foone there is no spoon, only strings and the numbers that's we authoritatively assign them
       
 (DIR) Post #Ajus8K5mPoBdxUG0um by GinevraCat@toot.community
       2024-07-14T08:56:32Z
       
       0 likes, 0 repeats
       
       @foone I lol'd so much at this brilliant thread. I didn't know live tooting of (to me) obscure programming learning could be that funny!
       
 (DIR) Post #Ajuvuy3fQSfDfn9kOG by foone@digipres.club
       2024-07-14T09:39:01Z
       
       0 likes, 0 repeats
       
       @DPA yeah. but this is also teaching me rust as a side-effect
       
 (DIR) Post #Ajuw2EC3pilBk8Xnwu by foone@digipres.club
       2024-07-14T09:39:58Z
       
       0 likes, 0 repeats
       
       I am making some kind of progress. I handled my Test file. variable references are now handled enough to not need to hardcode any of the metadata. Next step is to actually handle looking up variables
       
 (DIR) Post #AjuwDDJ1TRy2Aw2Tqa by foone@digipres.club
       2024-07-14T09:40:50Z
       
       0 likes, 0 repeats
       
       because you're supposed to be able to use this syntax:$red=RGB(255,0,0)Rectangle (0,50), (200,60), $redThe first line works. The second doesn't yet.
       
 (DIR) Post #AjuwDG27KlE8dN9WPg by foone@digipres.club
       2024-07-14T09:41:15Z
       
       0 likes, 0 repeats
       
       this was working before, and I broke it. But I'm breaking it to be more generic
       
 (DIR) Post #AjuwDHTnxIy77X79Cy by foone@digipres.club
       2024-07-14T09:41:52Z
       
       0 likes, 0 repeats
       
       because the previous implementation was color-specific.But you should be able to do this too:$red=RGB(255,0,0)$startpoint = (0,50)Rectangle $startpoint, (200,60), $red
       
 (DIR) Post #AjuwXjaj99vg6C6a2a by foone@digipres.club
       2024-07-14T09:42:55Z
       
       0 likes, 0 repeats
       
       I've been yelling at rust for 10 hours today. I think that's enough for now.
       
 (DIR) Post #Ajuy7Xy7w7lmQngtPM by EsinComics@toot.garden
       2024-07-14T10:03:43Z
       
       0 likes, 0 repeats
       
       @foone And they say C++ is unsafe
       
 (DIR) Post #Ajuytl3SaP2yuuArCK by rk@mastodon.well.com
       2024-07-14T10:12:31Z
       
       0 likes, 0 repeats
       
       @foone Rust timeMore like rest time amirite
       
 (DIR) Post #AjuzpPtpOoXq6IA91E by foone@digipres.club
       2024-07-14T10:22:14Z
       
       0 likes, 0 repeats
       
       @retroswim I used to be a VB programmer! I know the pain!
       
 (DIR) Post #Ajv2niJmFSQmVYBCnA by chakie@toot.community
       2024-07-14T10:55:39Z
       
       0 likes, 0 repeats
       
       @foone Love your Rust journey. I haven’t done anything serious with it yet, but would probably yell at it the same way as you if I were. I find that slowly reading through the Rust book and testing things with tiny apps works well as I have no deadlines nor things that must be done with Rust.
       
 (DIR) Post #AjvByiyJ3cQ9JAShmK by ppxl@social.tchncs.de
       2024-07-14T12:39:18Z
       
       0 likes, 0 repeats
       
       @foone you case really doesn't help me to learn Rust in the first place 🥲
       
 (DIR) Post #AjvHpzu9KarswYjum8 by nougcat@ohai.social
       2024-07-14T13:43:34Z
       
       0 likes, 0 repeats
       
       @foone may i recommend scribe.rip?https://scribe.rip/@wastedintel/reference-iterators-in-rust-5603a51b5192
       
 (DIR) Post #AjvJE8gKRwLF4MLnFY by vikriti@dopamine.social
       2024-07-14T13:59:25Z
       
       0 likes, 0 repeats
       
       @foone seems like rust has been screaming back
       
 (DIR) Post #AjyKV4JCe0klrG39Jw by foone@digipres.club
       2024-07-16T00:58:33Z
       
       0 likes, 0 repeats
       
       now I'm trying to figure out how to handle the type system for my language I'm implementing in Rust, without having to fight the type system OF rust.
       
 (DIR) Post #AjyKsN8ApXWatV0FFI by foone@digipres.club
       2024-07-16T01:02:51Z
       
       0 likes, 0 repeats
       
       since every command in VFL has specific types it takes for each argument. And right now this is represented by the enums for each of the commands taking those types of arguments.
       
 (DIR) Post #AjyKyNzYXfGHImq86C by foone@digipres.club
       2024-07-16T01:03:52Z
       
       0 likes, 0 repeats
       
       but right now I'm trying to add variables back into the language. and because of where these enums are used in the parser, I'd need to change all those types to be ReferenceOrLiteral, losing that type info.
       
 (DIR) Post #AjyL53jEHMC2U2Nw80 by foone@digipres.club
       2024-07-16T01:04:15Z
       
       0 likes, 0 repeats
       
       maybe I should learn how generics work?Then it could be ReferenceOrLiteral<String>,
       
 (DIR) Post #AjyMSwekKDd3SAF2w4 by wez@fosstodon.org
       2024-07-16T01:20:32Z
       
       0 likes, 0 repeats
       
       @foone not sure if this actually is helpful here, but maybe look at Cow<str>?
       
 (DIR) Post #AjyNn6wxrWy37nwWYa by foone@digipres.club
       2024-07-16T01:35:34Z
       
       0 likes, 0 repeats
       
       @wez I don't think so. To be clear, these are references in VFL, the language I'm implementing, not references in rust. So this fixes a problem at the wrong layer.
       
 (DIR) Post #Ajyr54AfpXLaODGkhE by billgoats@bitbang.social
       2024-07-16T07:03:29Z
       
       0 likes, 0 repeats
       
       @foone I first read this as ‘how genetics work’, and the answer would have to be yes! 🧬
       
 (DIR) Post #Ak0hQcmFkZVuZfPKNs by foone@digipres.club
       2024-07-17T04:24:53Z
       
       0 likes, 0 repeats
       
       I skipped generics. now I'm just trying to write a generic resolve function that takes a ReferenceOrLiteral and turns it into a TypedValue, but I'm not sure how to make the references work. I'm gonna have to understand that lifespan syntax
       
 (DIR) Post #Ak0iWGfAyzr1gELtcu by foone@digipres.club
       2024-07-17T04:37:16Z
       
       0 likes, 0 repeats
       
       wasn't an issue! and now I have at least one command working with proper variable indirection.
       
 (DIR) Post #Ak0jaqjUv062f27dTM by foone@digipres.club
       2024-07-17T04:49:23Z
       
       0 likes, 0 repeats
       
       me: I don't need to support $foo=$bar syntax. You can only assign variables with literals, not other variables.also me: I wrote one of the example files using that syntax
       
 (DIR) Post #Ak0kCioenjMd6yauUy by foone@digipres.club
       2024-07-17T04:56:11Z
       
       0 likes, 0 repeats
       
       okay that wasn't too hard to fix.
       
 (DIR) Post #Ak0lXQropWrRTlVqN6 by foone@digipres.club
       2024-07-17T05:10:51Z
       
       0 likes, 0 repeats
       
       whoops I figured out how to implement fonts in my flag language
       
 (DIR) Post #Ak0mjSr9MNcj4sV7a4 by xorn@mastodon.social
       2024-07-17T05:24:14Z
       
       0 likes, 0 repeats
       
       @foone A flag language should be good for multithreaded programming because of semaphores
       
 (DIR) Post #Ak0nu3xUMy6qzx5ErA by foone@digipres.club
       2024-07-17T05:37:19Z
       
       0 likes, 0 repeats
       
       @xorn hah!
       
 (DIR) Post #Ak0pHGkj4DxzIEk8vY by foone@digipres.club
       2024-07-17T05:53:11Z
       
       0 likes, 0 repeats
       
       my language should now be case insensitive.except for variables. right now those are case-sensitive.
       
 (DIR) Post #Ak0sbUnIs1FIUqHk5Q by foone@digipres.club
       2024-07-17T06:30:01Z
       
       0 likes, 0 repeats
       
       now I'm trying to figure out how to assign a fixed-length string, and failing.I can turn "hello world" into a [u8] by doing .as_bytes() but I can't assign that to a [u8;11]
       
 (DIR) Post #Ak0t9cVOhsDGG4BJx2 by carey@mastodon.nz
       2024-07-17T06:36:05Z
       
       0 likes, 0 repeats
       
       @foone b"hello world" is &[u8; 11], so you can assign *b"hello world" to a fixed-length array.Otherwise, you'll probably use copy_from_slice() which will be optimised to something very similar anyway.
       
 (DIR) Post #Ak0tJOkwgGiyVm7IJs by foone@digipres.club
       2024-07-17T06:37:38Z
       
       0 likes, 0 repeats
       
       apparently the magic I need is .try_into()
       
 (DIR) Post #Ak0tSVC47FXL5D8utU by foone@digipres.club
       2024-07-17T06:38:29Z
       
       0 likes, 0 repeats
       
       so now I gotta finish implementing a binary writer for the FLG bytecode, which is only really documented in the kaitai struct code I used to read it before, which is also wrong, because I've changed some things about the language since then. I think.
       
 (DIR) Post #Ak0tSYBoyc7kNK3GQi by foone@digipres.club
       2024-07-17T06:38:36Z
       
       0 likes, 0 repeats
       
       that's enough rust for one day
       
 (DIR) Post #Ak0vofEBgniSTzpZK4 by foone@digipres.club
       2024-07-17T07:06:18Z
       
       0 likes, 0 repeats
       
       @dysfun that's fine, and in fact needed: I'm writing a binary file, so I need it to be the correct length or it'll break.
       
 (DIR) Post #Ak0y6RrSKBzW9Do2t6 by lambda@chaosfurs.social
       2024-07-17T07:31:31Z
       
       0 likes, 0 repeats
       
       @foone you probably want a "byte string" literal, b"hello world". It only allows ASCII (and escape sequences), but it's a [u8; 11].
       
 (DIR) Post #Ak14uJFvC1P9f9POkK by dryak@mstdn.science
       2024-07-17T08:47:49Z
       
       0 likes, 0 repeats
       
       @foone a CVE for root privileges escalation in a font/flag-script when? :-D
       
 (DIR) Post #Ak6SBTShlkL4yYLE9Y by foone@digipres.club
       2024-07-19T22:57:53Z
       
       0 likes, 0 repeats
       
       now I gotta figure out how to do an enum that works like a C++ enum. like, I need it to have integer values.rust's enums where they can contain all kinds of data per value is neat, but I need the enum to be a 0x04
       
 (DIR) Post #Ak6SwHu0Z6UqjbR0bo by foone@digipres.club
       2024-07-19T23:04:12Z
       
       0 likes, 0 repeats
       
       this is easy, just stick =0, =1, =2 after the enum names, but the trick is getting the binary-writing crate I'm using into actually writing them out, since it doesn't really know what to do with enums
       
 (DIR) Post #Ak6T7sdCLfGdpg6EjI by xgranade@wandering.shop
       2024-07-19T23:04:47Z
       
       0 likes, 0 repeats
       
       @foone I think you're looking for discriminants and #[repr(u8)] (or however many byes wide your enum is).https://doc.rust-lang.org/reference/items/enumerations.html#discriminants
       
 (DIR) Post #Ak6TSErhOQj0a6adXc by str4d@abyssdomain.expert
       2024-07-19T23:13:40Z
       
       0 likes, 0 repeats
       
       @foone I enjoy your long discovery threads like this! Do you want Rust pointers from other people in this one? (I don't want to drop references to the relevant documentation unless you actually want them.)
       
 (DIR) Post #Ak6Ut9A2oCX8fBZ7OS by otte_homan@theblower.au
       2024-07-19T23:30:59Z
       
       0 likes, 0 repeats
       
       @foone use a ".from()" to get the input source correct?
       
 (DIR) Post #Ak6VfeEyYiBWxG013Y by foone@digipres.club
       2024-07-19T23:38:29Z
       
       0 likes, 0 repeats
       
       @str4d Sure.
       
 (DIR) Post #Ak6VnBV5IXYO8S7yV6 by foone@digipres.club
       2024-07-19T23:39:01Z
       
       0 likes, 0 repeats
       
       @kevin god damn, you're right. they're basically an enum+union combo, but moreso the union half
       
 (DIR) Post #Ak6WFxoFHOu04UoT32 by str4d@abyssdomain.expert
       2024-07-19T23:47:01Z
       
       0 likes, 0 repeats
       
       @foone @kevin They're effectively tagged unions and can thus be used safely, as opposed to real unions, which Rust also has and requires unsafe{} to read: https://doc.rust-lang.org/reference/items/unions.html
       
 (DIR) Post #Ak6WZpRq4p0nvlnyAS by str4d@abyssdomain.expert
       2024-07-19T23:48:15Z
       
       0 likes, 0 repeats
       
       @foone which crate are you using?
       
 (DIR) Post #Ak6WkIMzOvl0WfWlDE by foone@digipres.club
       2024-07-19T23:50:10Z
       
       0 likes, 0 repeats
       
       @str4d BinWrite:https://docs.rs/binwrite/latest/binwrite/
       
 (DIR) Post #Ak6WrbHfTdfJDLWPJI by foone@digipres.club
       2024-07-19T23:51:00Z
       
       0 likes, 0 repeats
       
       That's all fixed. just defined a preprocessor to turn the enum into an integer (u8) that BinWrite knows how to write
       
 (DIR) Post #Ak6WrdY33hxMEjCW7U by foone@digipres.club
       2024-07-19T23:52:22Z
       
       0 likes, 0 repeats
       
       One thing I'm not yet comfortable yet in rust is writing rust-style code. I keep trying to write very pythonic DRY code and rust's type system is like "no, don't".and I end up having to write it more like C++, which results in a bit more copy-pasted boilerplate than I would be happy with in python
       
 (DIR) Post #Ak6XRjSQZ7EyzNmd4S by str4d@abyssdomain.expert
       2024-07-20T00:01:20Z
       
       0 likes, 0 repeats
       
       @foone I don't see any enum support, but it has a preprocessor option that can probably be used to work around it: https://docs.rs/binwrite/0.2.1/binwrite/trait.BinWrite.html#using-a-preprocessor
       
 (DIR) Post #Ak6YLsNqZ6vStDPciO by hank@idlethumbs.social
       2024-07-20T00:11:46Z
       
       0 likes, 0 repeats
       
       @foone you can `#[repr(u8)]` but I think you still need to `unsafe` and `as`
       
 (DIR) Post #Ak6ZhMVxpmuKNH1Bya by foone@digipres.club
       2024-07-20T00:26:45Z
       
       0 likes, 0 repeats
       
       this is supposed to be the rainbow flag. clearly something is /slightly/ wrong
       
 (DIR) Post #Ak6ZtHk1PIFl2sHLzE by parsingphase@m.phase.org
       2024-07-20T00:28:46Z
       
       0 likes, 0 repeats
       
       @foone That's clearly the goth rainbow flag. Seen it many times in my misspent youth.
       
 (DIR) Post #Ak6bl0kosf9Px6pns0 by Kiloku@burnthis.town
       2024-07-20T00:49:44Z
       
       0 likes, 0 repeats
       
       @foone as seen through the eyes of a being with a sight spectrum starting slightly beyond ultraviolet
       
 (DIR) Post #Ak6ccDqYvux7uFtTKy by foone@digipres.club
       2024-07-20T00:59:20Z
       
       0 likes, 0 repeats
       
       ahh!the way my rectangles work is backwards: I thought it was point-1, point-2, and then the color.nope! I put the color at the beginning, because basically every command has a color. so I need to either fix how my code writes it, or change how my code reads it
       
 (DIR) Post #Ak6ckzUNgURdyzhRI0 by foone@digipres.club
       2024-07-20T01:00:05Z
       
       0 likes, 0 repeats
       
       BINGO
       
 (DIR) Post #Ak6dcHkaWGaVy2h2GG by hp@mastodon.tmm.cx
       2024-07-20T01:08:38Z
       
       0 likes, 0 repeats
       
       @foone it's just the rainbow flag at night. We don't stop being queer just because the lights are off.In other words: perfect rendering, no problems. Job done.
       
 (DIR) Post #Ak6diA7tmJW63kOn8C by foone@digipres.club
       2024-07-20T01:09:36Z
       
       0 likes, 0 repeats
       
       okay so now I can do a full path from a VGA Flag Language (VFL) file, into the rust code, which compiles it into bytecode, which the vgapride-bytecode branch can read. At least for rectangles.So I need to implement ellipses and polygons and lines and crabs, then the same in the vgapride-bytecode branch, then port that BACK to DOS. but this is a major step.
       
 (DIR) Post #Ak6eZyQhTykVQ6quae by MishaVanMollusq@sfba.social
       2024-07-20T01:21:00Z
       
       0 likes, 0 repeats
       
       @foone did you taste the Rainbow here ?
       
 (DIR) Post #Ak6uslvjmHOnQGM66a by oblomov@sociale.network
       2024-07-20T04:24:09Z
       
       0 likes, 0 repeats
       
       @foone it's clearly the rainbow flag in a moonless night
       
 (DIR) Post #Ak7DeESpJ2cyhgc4OG by wasamasa@lonely.town
       2024-07-20T07:47:30Z
       
       0 likes, 0 repeats
       
       @foone Can't really make sense of your writings on VFL, bytecode and so on, but is any of that code online? Kinda tempted to port the flag generation parts to Emacs and having machine-readable flag definitions sounds better than rewriting the C++/BASIC code I've found on GitHub so far.
       
 (DIR) Post #Ak7EKr0WOPPWPGhHiC by foone@digipres.club
       2024-07-20T07:57:09Z
       
       0 likes, 0 repeats
       
       @wasamasa not yet. There's a doc here with some info on how the language works:https://wiki.foone.org/w/VGA_Flag_Languageand some example files here:https://gist.github.com/foone/11087057c4cf49c93212045e1e7e2b44(the jewish one is wrong: the #include should be a filename, not a flag name)
       
 (DIR) Post #Ak8Jggx99JkUWUJL3g by Jhynjhiruu@toot.wales
       2024-07-20T20:36:33Z
       
       0 likes, 0 repeats
       
       @foone BinWrite (or, certainly, its rewritten replacement BinRW, which I think is mostly drop-in) supports writing enums directly.
       
 (DIR) Post #Ak8LA2aHu4uhxnB3my by foone@digipres.club
       2024-07-20T20:49:38Z
       
       0 likes, 0 repeats
       
       @Jhynjhiruu BinWrite doesn't seem to, but I'll have to check out BinRW. Thanks!
       
 (DIR) Post #Ak8LeQONwypgUS69nk by Jhynjhiruu@toot.wales
       2024-07-20T20:58:08Z
       
       0 likes, 0 repeats
       
       @foone If you switch to BinRW (I'd recommend it), it's something like #‌[brw(magic(0x00))], or there might be a nicer way of doing it I've forgotten - the docs are super well written, and there's also a Discord server for it if you're into that
       
 (DIR) Post #AkENQeMeZU3KctbiDY by miniBill@mastodon.uno
       2024-07-23T18:46:47Z
       
       0 likes, 0 repeats
       
       @foone @wasamasa Had some fun: https://elm-vga-flag-language.netlify.app/