|
Rothon posted:Rust By Example is in a similar style to the Go tour. There's also the Rust Book which a more traditional format. I'm kind of offended by hello world being implemented with a macro.
|
# ¿ May 16, 2015 11:40 |
|
|
# ¿ Apr 28, 2024 01:08 |
|
Rothon posted:It allows format arguments to be verified by the compiler. You could write the string literal directly to the stdout writer if you wanted to, but it's much more common to just use println!. It's basically equivalent to doing I mean, I guess it comes down to whether a hello world implementation is meant to demonstrate idiomatic code or whether it's meant to give insight into how the language operates. The macro completely obfuscates whatever is going on there and as far as I know, it could be hiding java levels of boilerplate (which would be fine or even cool).
|
# ¿ May 16, 2015 19:25 |
|
I did some rust this weekend and I will feel pretty convinced that it's going to be a big deal. I know you were all anxious to get my opinion so there it is.
|
# ¿ Jun 14, 2015 19:42 |
|
Ralith posted:The author of error-chain has posted a nice introduction to the newest release which reveals that my use of foreign_links above was somewhat less than idiomatic and makes a better case for why it's worth using beyond saving boilerplate. Oh wow, this is so cool.
|
# ¿ Dec 2, 2016 03:05 |
|
Ralith posted:You can chain_err any Result type if you have the symbols from a module containing an error_chain! invocation in scope. The method comes from a macro-generated ResultExt trait, and it returns the type of Result defined by that macro. For simple command-line tools, I often just have "error_chain! {}" at the top of the file so I can provide nice detailed information-preserving textual error messages everywhere. Do you have any good examples of command line tools written in rust?
|
# ¿ Dec 9, 2016 20:38 |
|
Ralith posted:The tools I've been writing recently wouldn't make much sense to share, but I hear ripgrep is pretty neat. If you're looking for examples of error-chain use specifically, the best I can do is suggest you page through the reverse dependency list. Maybe Xargo? Thanks for reminding me of rip grep. I'd been meaning to check out this code review of ripgrep, and it is indeed pretty fantastic for language learners. (Thanks for the other links too, I'll check them out).
|
# ¿ Dec 10, 2016 16:36 |
|
So, I want to parse a protobuf result and then match over the possible return types, but I've got no idea how to to do it. Protobuf types: code:
code:
I understand that it cant `parse_from_bytes` without a concrete type to return. I think I'm just using the protobuf library wrong but it has very little documentation so I'm just trying to follow the compiler to victory. DONT THREAD ON ME fucked around with this message at 23:05 on Dec 18, 2016 |
# ¿ Dec 18, 2016 23:01 |
|
Ralith posted:You can explicitly specify type parameters by calling a function with syntax like "parse_from_bytes::<MyMessageType>(m)". You may also get better results from inference once you've actually entered some cases that entail a specific concrete discriminant type. boo! I tried that but I was doing parse_from_bytes<MyMessageType>(m). The parse errors probably should have clued me in. And yeah, I'm still getting used to error handling, but I recognize that by just calling unwrap, I'm failing to handle errors.
|
# ¿ Dec 18, 2016 23:30 |
|
Yeah, refactoring can be super annoying, especially if you're adding or removing a lifetime or something. Fortunately, there's nothing stopping rust from having very powerful tooling, so I think it's just a matter of time.
|
# ¿ Jan 3, 2017 19:37 |
|
Asymmetrikon posted:I think my least favorite thing about refactoring so far has been trying to isolate parts of a chain of iterators. The result of a .map().filter().whatever() has a gnarly result type. There's also inspect: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.inspect
|
# ¿ Jan 3, 2017 21:07 |
|
So, I'm at a point with rust where I am comfortable with all of the syntax, but am still struggling with borrowing, lifetimes and references. This tutorial is tremendously helpful: http://cglab.ca/~abeinges/blah/too-many-lists/book/README.html It walks you through building a number of linked lists, gradually increasing in complexity. It specifically addresses things like Box, Rc, Arc, mem::Replace, &mut, *mut, *const, Copy, and how you'll need to use those things to build a simple data structure in Rust. It's really helped me. The format is a little annoying (probably too jokey for most people's taste) but the content is solid. DONT THREAD ON ME fucked around with this message at 19:01 on Jan 7, 2017 |
# ¿ Jan 7, 2017 18:59 |
|
I really like rust and I can't wait for it to become employable so I can get a job writing it.
|
# ¿ Jul 17, 2017 23:04 |
|
I'm playing with Rocket and Diesel -- they're the first real frameworks I've tried in rust (tokio is probably the largest library I've dealt with). CodeGen and Macros are going to ruin this language. http://docs.diesel.rs/diesel/macro.infer_table_from_schema.html I'm flabbergasted that the compiler even makes this possible. I'm doubly flabbergasted that Diesel presents this in their tutorial as the way to generate their schema.
|
# ¿ Aug 12, 2017 04:42 |
|
Sagacity posted:I think this is a pretty bad idea too but, to be fair, languages like Java do a ton of this stuff at compile time too, e.g. Jooq. What I dislike most about macro based DSLs is that inevitably they will end up like C++-style template monstrosities that are poorly documented and where there is no hope of sane autocompletion. What concerns me is that rust made this incredibly easy. Yes, I was importing a crate called `_codegen`, which should have tipped me off, but beyond that it's just a macro. If this were enabled as part of a plugin, it would be a different story. Macros should not be able to do this, and now I'm going to have to be incredibly suspicious of every single macro I encounter because it could be doing network insanity at compile time. (I could be mistaken about some of this, I haven't actually figured out how this macro works yet). DONT THREAD ON ME fucked around with this message at 19:59 on Aug 12, 2017 |
# ¿ Aug 12, 2017 19:54 |
|
Weird, it never occurred to me that you could use custom derive like that. I assume procedural macros will allow similar behavior? If so I really hope they gate them somehow because I really don't want things like this to be standard macro behavior. But to Ralith's point, it's not like I ever really use a macro without understanding what it does, so maybe it's okay.
|
# ¿ Aug 13, 2017 22:59 |
|
Ralith posted:Procedural macros should generally be the exception, at least once declarative macros 2.0 lands. Hell, any kind of macros at all should be the rare exception, much less complicated ones. It's good to have escape hatches in a language, even if some people will always be tempted to treat the escape hatch more like a revolving door. I think I've misunderstood the state of macros. My understanding was the procedurals macros were macros 2.0, but it sounds like you're saying that's not the case. Guess I have some reading to do.
|
# ¿ Aug 14, 2017 00:01 |
|
Yeah the intellij plugin is much better right now. RLS will likely be the superior choice eventually but it’s not there yet.
|
# ¿ Dec 11, 2017 13:30 |
|
Beamed posted:VS code shows me compiler/syntax errors immediately, quote:lets me ctrl+click into library code to read some APIs, quote:in-built terminal i have no doubt that RLS will be the way to go eventually but it wasn't there last time I tried it (admittedly, around 6 months ago, haven't been doing much rust lately). DONT THREAD ON ME fucked around with this message at 02:50 on Feb 14, 2018 |
# ¿ Feb 14, 2018 02:38 |
|
Beamed posted:Nope, don't get this. That's weird friend, I dunno. Works on my machine, I guess!
|
# ¿ Feb 14, 2018 05:00 |
|
I'm implementing Raft (for learning) and I'm using async/await futures 0.3 in compatibility with tokio 0.1. It's still a pain in the rear end (mostly due to issues with the compat shims at this point) but async/await is way nicer to work with than chaining 0.1 futures. I'm actually getting stuff done instead of spending hours trying to understand why my types aren't lining up. It's going to be good eventually.
|
# ¿ Feb 14, 2019 19:34 |
|
|
# ¿ Apr 28, 2024 01:08 |
|
1. Yeah, I think you should absolutely stick with ws-rs for exactly the reasons you mentioned. Or maybe write your own websockets implementation. If you want to get more serious I'd consider tokio, which will handle (2) for you. 2. You probably want the nomicon, https://doc.rust-lang.org/nomicon/ IMO rust docs do a good job of educating people about the happy path but I've had a really hard time learning the lower level/unsafe details (this is definitely partly due to my own inexperience with lower level languages, rust was my first). 3. RLS is the biggest disaster in Rust ATM. I have faith that it will get there eventually but it's just not usable and it should not be recommended to new users. Intellij rust plugin is way way way way way way, way way better. DONT THREAD ON ME fucked around with this message at 17:47 on May 31, 2019 |
# ¿ May 31, 2019 17:42 |