These are chat archives for rust-lang/rust

11th
Aug 2017
Igor
@target-san
Aug 11 2017 07:54

Didn't want to pollute forum, so posting here.
There's a known limitation:

struct Spam<T: Eggs> { ... }
// right
impl<T: Eggs> Bacon for Spam<T> { ... }
// wrong, missing T: Eggs
impl<T> Bacon for Spam<T> { ... }

So the question is, why constraint isn't propagated implicitly in this case, and in similar ones? Was there some discussion why not?

Michal 'vorner' Vaner
@vorner
Aug 11 2017 07:59

You can have different constraints on impl. You could, for example, have:

impl<T: Eggs + Clone> Bacon for Spam<T> { ... }

You'd put methods that only the ones with clone as well support.

Denis Lisov
@tanriol
Aug 11 2017 08:02
Discussion is in progress in the implied bounds RFC rust-lang/rfcs#2089
Aleksey Kladov
@matklad
Aug 11 2017 08:02
From the practical point of view, there's an opinion that one should avoid bounds on structs altogether, if possible, and place bounds on impls instead: https://users.rust-lang.org/t/should-i-put-where-bounds-on-the-struct-or-on-the-impl/7064/8
Igor
@target-san
Aug 11 2017 08:09
@vorner I mean impl<T: Clone> Bacon for Spam<T> { ... } -> impl<T: Eggs + Clone> Bacon for Spam<T> { ... } implicitly - because it's implied by struct itself, anyway
@matklad Maybe. Though, in my opinion, certain bounds are needed for the whole type just to make it function properly. As an example, HashMap also doesn't have such bounds - but doing anything sensible with it requires K: Eq + Hash, S: BuildHasher in almost all cases - except maybe Clone
@tanriol Thanks for link
Timmy Jose
@timmyjose
Aug 11 2017 09:16
Hey folks, working through Dominik Picheta's excellent book, "Nim in Action". Just curious - if I want to interface Nim with Java, say write a module in Nim and then load that using Java, I would have to simply bundle the compiled c code into a lib and load with JNI/JNA into Java. Is this the idiomatic way?
Aleksey Kladov
@matklad
Aug 11 2017 09:17
@timmyjose are you looking for https://gitter.im/nim-lang/Nim perhaps?
Timmy Jose
@timmyjose
Aug 11 2017 09:17
Oops... sorry about that! :P, yes you're right... wrong channel! :D
Aleksey Kladov
@matklad
Aug 11 2017 09:18
:)
Timmy Jose
@timmyjose
Aug 11 2017 09:18
That's the result of one beer too many! :D
Max Frai
@max-frai
Aug 11 2017 09:19
@timmyjose btw, it's the only way in any language that could be compiled into shared library
Timmy Jose
@timmyjose
Aug 11 2017 09:19
Yes, that makes sense
Michal 'vorner' Vaner
@vorner
Aug 11 2017 09:22
@target-san I would probably find it confusing, if the impl didn't list them all, but only some of them. I would prefer some kind of constrain aliases, the same way type can create an alias for a complex type.

Also, you can write things like (I think):

impl<T: Iterator> Bacon for Spam<T::Item> {

}

And I'm not sure the implicit rules there would be very helpful. What I like about rust (compared to C++, for example) is that it doesn't stab me in the back when I don't look at it. In C++, all these implicit rules start interacting and then you spend half a day trying to understand what happened and why. Therefore, I wouldn't like any complex implicit rules.

Zakarum
@omni-viral
Aug 11 2017 09:29
@vorner exactly what I would say :smile:
Consider this.
trait Eggs {
    fn doo_eggs_thing(&self);
}
struct Spam<T: Eggs>(T);

// and then in another crate where `Bacon` is declared.
impl<T> Bacon for Spam<T> {
    fn do_bacon_thing(&self) {
        self.0.do_eggs_thing(); // Reader: "Whoa? Where does this method come from?"
    }
}
Restioson
@Restioson
Aug 11 2017 12:23
What do you guys use for editing rust?
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:24
Restioson
@Restioson
Aug 11 2017 12:24
I'm using that currently too, but I'm not so sure about VSC
:/
Aleksey Kladov
@matklad
Aug 11 2017 12:25
I use IntelliJ IDEA :)
Restioson
@Restioson
Aug 11 2017 12:25
I tried the plugin out for that too
has nice cargo integration
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:26
I am using Notepad++ and cmd.exe
Restioson
@Restioson
Aug 11 2017 12:26
Unfortunately I'm under windows and hence need to use WSL to build (for AVR microcontrollers)
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:26
I use it mostly because I want to help RLS's development at least by testing it
Restioson
@Restioson
Aug 11 2017 12:26
True, true. I was going to use Atom + RLS but the plugin seems to be somewhat broken
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:27
Atom and VSCode are not same thing?
Restioson
@Restioson
Aug 11 2017 12:27
They both use RLS but the atom plugin seems to have issues connecting to it
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:27
So what is the reason to use buggy atom than true programmers VSCode?
Restioson
@Restioson
Aug 11 2017 12:28
Ahem?
I'm using VSC at the moment because Atom's RLS plugin is broke, but when its fixed I will use Atom
Wish intellij supported rls : (
Aleksey Kladov
@matklad
Aug 11 2017 12:30
The current plan is, in the usual JetBrains way, to implement everything ourselves :)
Restioson
@Restioson
Aug 11 2017 12:30
Let's not have a flamewar though
Ah, I see
It's got nice syntax inspections
So might switch back, because VSC's RLS plugin doesn't actually seem to be doing much
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:32
vscode's plugin is the main playground for RLS, as far as i know
Restioson
@Restioson
Aug 11 2017 12:32
Huh, i'm not getting any of those warnings...
Not even syntax errors
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:33
something is broken then
Restioson
@Restioson
Aug 11 2017 12:33
Yeah :/
its a clean install though
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:34
@Restioson which VSC version are you using?
Restioson
@Restioson
Aug 11 2017 12:34
Not the latest
huh, i'm apparently on a different vsc plugin...
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:35
@Restioson yes. vscode-rust and rls-rust are different plugins
Restioson
@Restioson
Aug 11 2017 12:36
:L
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:36
yeah, there're at least 3 rust plugins
Restioson
@Restioson
Aug 11 2017 12:36
I'm going to try the other one now, thanks!
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:36
sailorisdead, kalita-alexey and rust-lang
Restioson
@Restioson
Aug 11 2017 12:36
still holding out for jetbrains to finish their rust plugin
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:37
@Restioson Don't forget, with VSC you can debug your rust program
Restioson
@Restioson
Aug 11 2017 12:37
Not for my target i think
Embedded avr :smile:
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:37
if there are still problems with rls-vscode one, try reporting them to https://github.com/rust-lang-nursery/rls-vscode/issues
Restioson
@Restioson
Aug 11 2017 12:37
I was on the kalita-alexey one
Sherzod Mutalov
@shmutalov
Aug 11 2017 12:38
@Restioson also, someone using eclipse to writing rust programs.
Restioson
@Restioson
Aug 11 2017 12:38
i would never go back to eclipse
:p
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:39
btw, why do you prefer atom to vscode?
Restioson
@Restioson
Aug 11 2017 12:39
I prefer the UI
atom's git is somewhat bugged with keysigning though
Andrey Lesnikov
@ozkriff
Aug 11 2017 12:40
hmm, I have a little experience with atom - what's so good about its UI?
Restioson
@Restioson
Aug 11 2017 12:40
Dunno, just feels better to me
I wonder if I can configure VSC to use bash
Restioson
@Restioson
Aug 11 2017 12:57
Thanks!
Now to see how to run task from it
Zakarum
@omni-viral
Aug 11 2017 15:26
I just pressed something and my vscode started highlighting elements with #ff0000
Did somebody know how to turn it off?
Zakarum
@omni-viral
Aug 11 2017 15:31
Hmm... some problem with installed theme