These are chat archives for rust-lang/rust

16th
Nov 2018
฿€¢₭$
@Gee5ive
Nov 16 2018 01:02
@loloof64 I'd probably use https://crates.io/crates/web-view instead of electron
matrixbot
@matrixbot
Nov 16 2018 01:04
bspeice laurent bernabé (Gitter): I would also ask whether you're trying to do Electron plugins or WASM; For Electron plugins, https://www.neon-bindings.com/ is really great. For WASM... my personal experiments didn't go so well.
laurent bernabé
@loloof64
Nov 16 2018 07:00
Hi thanks for your answer. I just want to build an application that is multi platform, and that works as well in Debug and in Release mode. And also usable only with Rust Stable.
I'll try Web-View crate with Yew :smile:
Aleksey Halahan
@skyne98
Nov 16 2018 09:16
Hey, guys, I have a question, is using Syn crate a good choice for implementing a frontend for a language with Rust similar syntax, but some subtle differences?
Michal 'vorner' Vaner
@vorner
Nov 16 2018 09:17
@skyne98 Depends on the differences, but I'd expect it to bite you eventually. So maybe as a first PoC it might be good, but probably not long-term. However, maybe looking into the crate how it does its thing (maybe it has dependencies that do most of the heavy lifting) might be a good idea.
Aleksey Halahan
@skyne98
Nov 16 2018 09:19
I think Syn documentation mentiones that is constructed of parser functions and can actually be extended in any ways. Basically, I suppose you can build any kind of new syntax by implementing a Parse trait.
Michal 'vorner' Vaner
@vorner
Nov 16 2018 09:20
Well, then maybe the answer is yes. Hard to know without trying it out ;-)
Aleksey Halahan
@skyne98
Nov 16 2018 09:21
Yep, agree! Just hoped that maybe there are some Syn users out here :smile:
Sylwester Rąpała
@xoac
Nov 16 2018 11:59
What do u guys think about it: https://github.com/lovasoa/custom_error?
Not so much stars and looks awesome
Michal 'vorner' Vaner
@vorner
Nov 16 2018 12:00
In what way is that supposed to be better than the more commonly used crates for custom errors, like error-chain or failure?
Sylwester Rąpała
@xoac
Nov 16 2018 12:15
It's define it in standard minimal way. It's quick definition of std::Error + Display and also From<OtherError>
Michal 'vorner' Vaner
@vorner
Nov 16 2018 12:19
Right, what I mean is, the other crates also support these and they are already more popular and widely used and from a quick glance, with less rough edges around them. For example this: https://boats.gitlab.io/failure/derive-fail.html#enums
Sylwester Rąpała
@xoac
Nov 16 2018 17:01
Yep I have using it and decided to use std::Error instead and custom_error make it as easy as failure
Fernando Seror Garcia
@Ferdy89
Nov 16 2018 22:14

Hello all! :wave: I’m very new to Rust and I recently encountered this problem that I’ve spent a few hours on already

error[E0271]: type mismatch resolving `<std::env::Args as std::iter::Iterator>::Item == &str`

Here’s the full code in a playground. I’ve been able to make it work making Item = String but I feel like I should be able to take a slice in the function. I’m very interested in understanding the guts of the issue :) Thank you! :smile:

Denis Lisov
@tanriol
Nov 16 2018 22:44
This is an interesting question :-) there can be only one implementation of Iterator for Args and the one that does exist returns Strings, not string slices slices.
Why? Well, Rust code expects the arguments encoded in UTF-8 used normally everywhere in the language. However, at least Windows provides arguments in UTF-16 instead, so they have to be converted to UTF-8.
Fernando Seror Garcia
@Ferdy89
Nov 16 2018 23:00
Thank you for your help :) Would there be a way of converting Args into another Iterator that returned slices?
Denis Lisov
@tanriol
Nov 16 2018 23:07
You can collect the strings into a Vec and then make such an iterator. Won't work without collecting, sorry.
The iterators don't play nice with the idea of a reference valid only until the next element is requested.
Fernando Seror Garcia
@Ferdy89
Nov 16 2018 23:17
I’ll give that a try, thank you!