These are chat archives for rust-lang/rust

16th
Jun 2018
trsh
@trsh
Jun 16 2018 11:58
How do I extract get a copy out of Rc?
Alexander Mescheryakov
@XX
Jun 16 2018 12:30
@trsh
let a = Rc::new(5);
let b = (*a).clone();
assert_eq!(5, b);
trsh
@trsh
Jun 16 2018 12:33
@XX tnx. I already figure it out ;)
Dmitriy
@dpogretskiy
Jun 16 2018 12:34
look at Deref trait, iirc
Andrew Williams
@williamsandrew
Jun 16 2018 15:05

Anyone here familiar with LALRPOP? I can't tell if I'm hitting a bug or doing something dumb. Getting this error back from the parser which seems wrong/confusing:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnrecognizedToken { token: Some((8, Token(8, "in"), 10)), expected: ["\"!=\"", "\",\"", "\"in\"", "\"notin\"", "r#\"=?=\"#"] }', libcore/result.rs:945:5

trsh
@trsh
Jun 16 2018 15:06
Can I turn hash map to json string?
Without doing looops?
Fredrik Portström
@portstrom
Jun 16 2018 15:08
@trsh Yes. Just use serde_json::to_string.
trsh
@trsh
Jun 16 2018 15:15
ou cool, tnx @portstrom
trsh
@trsh
Jun 16 2018 15:38
@portstrom btw what is your coding setup for rust?
Atom, vscode?
Fredrik Portström
@portstrom
Jun 16 2018 15:39
Emacs
Initially I used Atom. It used more memory than I have in my computer, so the system froze every time I looked at it.
trsh
@trsh
Jun 16 2018 15:40
I use vscode with plugins
have to say, no way im satisfied.
It has some RTL runner for atocompletes and error checking, that frequently just dies
Emacs is apple stuff?
Fredrik Portström
@portstrom
Jun 16 2018 15:42
Emacs is 80s hacker stuff.
trsh
@trsh
Jun 16 2018 15:42
hehe
Fredrik Portström
@portstrom
Jun 16 2018 15:45
While most software has improved a lot since the 80s, the sad thing is that still no one has made a text editor that works better than those made in the 80s. I long for the day someone will do that.
Jeremy Lempereur
@o0Ignition0o
Jun 16 2018 15:53
what would "better" mean in this context? like faster? or with more refactoring features ?
Fredrik Portström
@portstrom
Jun 16 2018 16:08
@o0Ignition0o In this context it doesn't refer to improvements, but to not making things worse. New editors have plenty of advanced improvements, but they don't get the basic features right. For example why does Atom forget the previous thing I copied whenever I want to copy one more thing. In Emacs I can copy one thing and then another, and then paste the last thing I copied and then paste the second last thing I copied.
Jeremy Lempereur
@o0Ignition0o
Jun 16 2018 16:09
oh so it would be having more advanced features, without sacryfing the current really awesome ergonomics i guess, that makes sense
trsh
@trsh
Jun 16 2018 16:20
How to update cargos, like rustfmt?
Jeremy Lempereur
@o0Ignition0o
Jun 16 2018 16:28
@trsh They get auto updated when you run rustup update, dont they ?
trsh
@trsh
Jun 16 2018 16:28
duno
Jeremy Lempereur
@o0Ignition0o
Jun 16 2018 16:29
I think they do now
A Dinesh
@dineshadepu
Jun 16 2018 17:07
Hi I want to extract the executable name of the current file. https://play.rust-lang.org/?gist=7975e49a61b1ab27c50e5c133327327b&version=stable&mode=release . When I run the example in release mode It panics. I should split it at 'release' If I am releasing it. How to catch the panic and set split to release here
Fredrik Portström
@portstrom
Jun 16 2018 17:12
@dineshadepu Don't rely on searching for words in paths. It's a recipe for disaster. Try this: https://doc.rust-lang.org/std/path/struct.Path.html#method.file_name
A Dinesh
@dineshadepu
Jun 16 2018 17:22
I will make it more clear, I am creating a directory depending on the file name, If I am in examples and have file say 'sample.rs' then the output has to be in the same folder named 'sample'.
In this process I am failing to extract the executable name when I am releasing it in 'release' mode
As I am using 'debug' to split
Fredrik Portström
@portstrom
Jun 16 2018 17:23
Don't use a word to split :'(
A Dinesh
@dineshadepu
Jun 16 2018 17:25
Can I know some other way to getting the executable name with path @portstrom
Fredrik Portström
@portstrom
Jun 16 2018 17:25
Use the function I linked to.
Jeremy Lempereur
@o0Ignition0o
Jun 16 2018 17:25
any chance for you to split on "/" instead an do some more sorcery ?
Fredrik Portström
@portstrom
Jun 16 2018 17:26
Splitting on '/' is also dangerous because of platform differences.