|
Yo dudes; learning Rust, and struggling with the borrow checker and unexpected ungulates. Code: Rust code:
code:
code:
|
# ¿ Mar 16, 2018 11:55 |
|
|
# ¿ Apr 29, 2024 19:45 |
|
Thank you; that explanation and code sorted it out entirely; needed to dissect the cow. Related: Now I'm tackling out the uppercase-conversion (Replaced by "test" in my previous example. After changing the tail_letters iterator to chars instead of strings, this works: code:
code:
code:
code:
Dominoes fucked around with this message at 00:39 on Mar 17, 2018 |
# ¿ Mar 16, 2018 23:47 |
|
I'm counting one in each, excluding the type annotation. Ie to convert a String, as output by char.to_string(), to a &str, as required by re.replace_all.
Dominoes fucked around with this message at 01:19 on Mar 17, 2018 |
# ¿ Mar 17, 2018 01:17 |
|
Thanks Viking - that makes sense!
|
# ¿ Mar 18, 2018 09:11 |
|
Yo bros. Trying to do some matrix mult; ref the thread's title. Any wisdom from bros on how to make it compile?Rust code:
code:
code:
Dominoes fucked around with this message at 04:48 on Apr 22, 2018 |
# ¿ Apr 22, 2018 04:39 |
|
Thanks for looking at it dude. getting this now:code:
code:
code:
Dominoes fucked around with this message at 05:03 on Apr 22, 2018 |
# ¿ Apr 22, 2018 04:57 |
|
Dudes; got it to compile; I'lll post what happened if you like, but I have no idea and don't think it'll be useful since I just moved &s around rando until it worked.
|
# ¿ Apr 22, 2018 05:08 |
|
Thank you - that helps a lot!
|
# ¿ Apr 23, 2018 02:18 |
|
Any advice on separating dependencies for WASM and binaries? I have a project that both runs locally with main.rs, and can be used as a library for WASM/JS using lib.rs. When I try to compile WASM, one or more of the dependencies that I need to run locally, but not web, prevents the WASM compilation. If I remove the crashing lib from Cargo.TOML temporarily, main.rs can't find it, which then prevents the compile. It appears that renaming main.rs, and commenting out the failing dependency works. Is there a more elegant solution? How would you handle this? Dominoes fucked around with this message at 10:34 on May 21, 2018 |
# ¿ May 21, 2018 10:20 |
|
Nailed it. Went with the specify-dependencies approach for now; may switch to the separate lib approach later.
|
# ¿ May 21, 2018 20:58 |
|
Another one: Is there a way to make Rust's wasm-bindgen work with types other than basic numbers/string, and ones you created in your code? Eg, I can make it accept custom structs with the #[wasm_bindgen] macro, but unable to apply it to say, a HashMap from the standard library, or an Array from the ndarray crate.
Dominoes fucked around with this message at 23:43 on May 21, 2018 |
# ¿ May 21, 2018 23:38 |
|
Thanks; works!
|
# ¿ May 23, 2018 20:41 |
|
Hey dudes. How do you enter values in scientific notation?Rust code:
quote:error[E0599]: no method named `powi` found for type `{float}` in the current scope
|
# ¿ Sep 27, 2018 22:18 |
|
Ralith posted:The syntax is the same as in most programming languages, e.g. 9.109390e-31. Re: Linear's comment: It's interesting that a workaround would have been required if it were not for this shorthand.
|
# ¿ Sep 27, 2018 22:40 |
|
I'm referring to why the code I initially posted isn't also a valid solution. I don't understand what's going on, since const test: f64 = 1. * 10.; works.
Dominoes fucked around with this message at 23:56 on Sep 27, 2018 |
# ¿ Sep 27, 2018 23:53 |
|
Thanks dudes.
|
# ¿ Sep 28, 2018 00:41 |
|
Helicity posted:When does the borrow checker stop kicking me in the dick? It feels like since Rust emphasizes "correctness", what I'm trying to do, and have done in programs for years, is broken. I already had imposter syndrome - I don't need a language to tell me I suck.
|
# ¿ Nov 14, 2018 03:35 |
|
Hey bros; question on Macros. I've read the 2018 book page on Macros and a few tutorials. I've never seen anything like this in my programming experience; this is beautiful, and completely appropriate for a use case I'm about to describe: I'd like to build a frontend framework using bindgen. I'd like to make a custom syntax for making HTML elements, where I've defined an element to have attributes, style, a tag type, text, and children, most of which are optional. It looks like you can do a lot with macros; implement JSX/etc without regex and strings; make a whole new sub-language inside rust? There are no rules. Struct I'd like to make a nice creation syntax for: Rust code:
Rust code:
Dominoes fucked around with this message at 03:46 on Nov 19, 2018 |
# ¿ Nov 19, 2018 03:42 |
|
Arcsech posted:I don't know much about macros, but I just saw earlier today that someone beat you to this, you might be able to take a look at what they do: https://github.com/bodil/typed-html There's a popular lib called Yew that uses something similar to that, but it uses stdweb, vice bindgen. Any ideas on how to handle making proc macros a sep crate (as they evidently require) without being codependent with the main crate? It looks like in that and other examples, the proc_macro crate never refs the main crate; I think they're putting all the types that may need to be returned in it... which begs the question of what actually needs to be in the (main / outer) non proc-macro crate. Dominoes fucked around with this message at 06:00 on Nov 19, 2018 |
# ¿ Nov 19, 2018 04:31 |
|
Hey dudes. Running into an issue with passing closures around. I've distilled a somewhat-more detailed problem into the basics: Playground Rust code:
|
# ¿ Dec 4, 2018 03:49 |
|
Thanks a lot! The trick was the clone + move you mentioned.
|
# ¿ Dec 5, 2018 04:30 |
|
Looking for critique and suggestions for a web framework I'm working on. Repo. Mainly regarding the guide (Readme) and API. My goal is for this to be accessible to web programmers who are not familiar with Rust. Motivation was the messy JS tooling and ecosystem, and the poor documentation of existing Rust/WASM frameworks. I hope to publish it on crates.io within the next few weeks. I have an API I like, and a basic virtual DOM is almost ready with plenty of room for optimization. I have a good deal of work to do on cleaning up how events trigger; struggling on that one. Simple clicks etc work, but anything involving accessing event parameters (like text input) is a WIP. Also need to either integrate, or document wasm-bindgen's fetch API, and how you'd use it with Serde to communicate with a server. And a router. Dominoes fucked around with this message at 07:32 on Dec 9, 2018 |
# ¿ Dec 9, 2018 07:05 |
|
rt4 posted:I look forward to giving this a shot. I've been really frustrated with how the Yew project can't be bothered to write any useful docs and Elm just feels so tedious sometimes...
|
# ¿ Dec 9, 2018 17:57 |
|
crazypenguin posted:Is there a reason you're not having people use wasm-pack? For the first issue, the command is apparently wasm-pack build --target nomodules, but I can't get it working. Of note: Chat about no-modules edit: Attempted again now: running into an error about failing to read Cargo.toml. edit2: I should probably just submit issues/PRs instead of waiting; the maintainers seem like the type who'd appreciate it. Dominoes fucked around with this message at 19:21 on Dec 9, 2018 |
# ¿ Dec 9, 2018 19:02 |
|
I appreciate how in languages like Python and Rust, you can choose which functional concepts when you'd like (Often directly inspired by languages like Haskell), without the associated restrictions.
|
# ¿ Dec 9, 2018 20:26 |
|
Clippy is really, really good! My experience with linters: TSlint/Jslint, as supplied by Create-React-App: Mostly subjective style enforcement that makes the app a pain to transpile; ended up turning off most lints, then abandoning the tool. Clippy: Makes consistently good recommendations to make code more readable, avoid traps, and teach about language features.
|
# ¿ Dec 13, 2018 06:48 |
|
Hey dudes, published an initial v of my frontend-framework crate. Any suggestions/critique on API/docs etc would be appreciated. Or just making sure that you can get a hello-world working using the quickstart info. There's a nasty bug lurking somewhere in the vdom. edit: nasty bug fixed. Dominoes fucked around with this message at 00:24 on Dec 15, 2018 |
# ¿ Dec 13, 2018 18:24 |
|
Good call. Updated repo and quickstart.
|
# ¿ Dec 13, 2018 19:38 |
|
I'm working on a WASM frontend crate, seed
|
# ¿ Jul 13, 2019 15:31 |
|
Rust code:
For your request, nesting the structs will work fine and may be more transparent. The id-based approach here is more generalizable to rendering arbitrary scenes. Dominoes fucked around with this message at 05:06 on Aug 7, 2019 |
# ¿ Aug 7, 2019 04:50 |
|
Rust's made me a lazy programmer. If I hosed something up (especially while refactoring), I step through each compiler error, and bam! It works. Thought about this after reading This controversial Jonathan Blow article - he cites dynamically-typed footguns as a reason for unit testing... got me thinking that Rust's compiler and type system accomplishes some of the same things as aggressive unit-testing, without the API inertia.
|
# ¿ Dec 4, 2019 15:29 |
|
rt4 posted:I've been thinking lately that Javascript is the language where I really need unit tests because I have no idea what the code on my screen actually does
|
# ¿ Dec 5, 2019 00:01 |
|
Arcsech posted:And you don’t need a PhD in math to make sense of it, unlike Haskell
|
# ¿ Dec 8, 2019 03:56 |
|
I have a diff trait question: How do you find trait bounds in lib docs? Usually the docs and compiler messages are clear, but I'm striking out on both counts. Example: here. At the top, it defines bounds on I2C, but not I2CInterface
|
# ¿ May 7, 2020 19:09 |
|
Thank you; that sorts it out. Of note, some of the items in <> in that page are in the docs (and are linked), while most aren't. I'd assumed it not being in the docs meant it was a trait.
|
# ¿ May 7, 2020 21:56 |
|
Used a lifetime for the first time today. It's always been a feature I've never needed to use, in my range of Rust projects. The case was trying to format strs using byte buffers in a no_std / no allocator environment. The resulting &'static str needed to be tied to the buffer arg.
|
# ¿ May 31, 2020 00:49 |
|
Hey, just wanted to say, Rust owns. It has warts; Async can DIAF, the all collection-related functional syntaxes are a mess (escape hatch: the for loop), and generics are IMO a choice of last resort, not first option. The more dogmatic/idealistic parts of the community need to go away. (Ie the safety woke) That said... Show me else where you can find a language that respects user time, battery life, electricity use etc, and is also memory-safe, relatively smooth experience, has the good parts of functional programming etc. Bottom line is, you could imagine a language better than Rust, but it's currently the best we've got. C and C++ have so many syntax and program-structure warts and traps, ADA is impractical for many uses, and almost all other languages are slow. (Which IMO is disrespectful and rude, and why computer programs still have noticeable impact lag, laptops are crap battery life etc even as hardware improves). Dominoes fucked around with this message at 18:30 on Oct 25, 2022 |
# ¿ Oct 25, 2022 18:27 |
|
Yea def. Rust's built in tooling is outstanding. C and C++ build systems are a relative disaster. Feels like it comes down to a project -sprcific recipe that may or may not work depending on OS state
|
# ¿ Oct 26, 2022 18:19 |
|
StumblyWumbly posted:Wait what? Is this just a reference to how efficiently it executes, or does Rust have some kind of sleep state support? I'm coming from a low port ARM microcontroller world, and Rust has been on my "maybe someday" list for a while. You should try Rust on ARM. IMO well-suited to that domain. Which MCUs specifically? Dominoes fucked around with this message at 14:53 on Oct 27, 2022 |
# ¿ Oct 27, 2022 14:51 |
|
|
# ¿ Apr 29, 2024 19:45 |
|
Nice! U5 is cutting edge. I made a Rust HAL for STM32 that works on most newer families. Intent is to support U5, but waiting on the PAC (named register definitions generated from SVD) to come out from the `stm32-rs` team on that. Hopefully is pretty similar to L5.
|
# ¿ Oct 27, 2022 18:01 |