These are chat archives for rust-lang/rust

21st
Nov 2016
Nehal Hasnayeen
@Hasnayeen
Nov 21 2016 07:00
how to compare two strings? following doesn't work?
fn check_host_file(line: &str, name: &str) {
    if name.contains(line) {
        println!("hey {:?}", name);
    }
}
Nehal Hasnayeen
@Hasnayeen
Nov 21 2016 07:04
@shmutalov actually name is substring of line, how to compare that?
Sherzod Mutalov
@shmutalov
Nov 21 2016 07:05
@Hasnayeen try to change order: name.contains(line) to line.contains(name)
Nehal Hasnayeen
@Hasnayeen
Nov 21 2016 07:09
@shmutalov thanks, actually it was line.contains(name) but there was no match, that's why it wasn't printing anything, i feel so dumb, anyway thanks
Sebastian Blei
@iamsebastian
Nov 21 2016 14:07
Hi,
What's the best (best to read & speed) way to "LEFT JOIN" between two Vectors of two different structs?
I want to insert elements in a database, that not already in.
UniqueViolation is the keyword in postgres. But INSERT ... OR UPDATE statement like in MySQL is not that easy in postgres.
Is there a way to implement an Eq between two different structs and filter the iter based on this?
Sebastian Blei
@iamsebastian
Nov 21 2016 14:16
Ok, seems I've could try it with the difference implementation in BTreeSet
Max Hofer
@mh182
Nov 21 2016 15:15
@iamsebastian Postgresql 9.5 has an equivalent of Insert or update.
Krishna Bhogaonker
@00krishna
Nov 21 2016 18:00
Hey rust folks, just a quickie about calling C++ from Rust. Do I still have to wrap a C++ library in C and then use the Rust FFI to call that wrapper? I was not sure if anything has changed with that.
Ingvar Stepanyan
@RReverser
Nov 21 2016 18:03
@00krishna well you can use Servo's fork of rust-bindgen to automate most of the conversions/wrappers, but yeah, otherwise the underlying mechanism is still the same afaik
Krishna Bhogaonker
@00krishna
Nov 21 2016 18:04
@RReverser thanks for the tip. I will look into that.
Sebastian Blei
@iamsebastian
Nov 21 2016 18:06
@mh182 I've read about it, I think. I've done it for the moment with a LEFT JOIN and a diff set.
Peter Atashian
@retep998
Nov 21 2016 21:21
@00krishna Calling stuff with the C++ ABI directly from Rust is incredibly difficult still. Writing a wrapper C++ library that exports a C ABI is still easier than trying to invoke the C++ directly from within Rust
David Harvey-Macaulay
@alteous
Nov 21 2016 23:01
@retep998
Peter Atashian
@retep998
Nov 21 2016 23:01
@Alteous Hi
David Harvey-Macaulay
@alteous
Nov 21 2016 23:01
Isn't that true of all C++ libraries?
Peter Atashian
@retep998
Nov 21 2016 23:02
What I said applies to any C++ library
David Harvey-Macaulay
@alteous
Nov 21 2016 23:03
I think that's more of a problem with C++ than Rust. I'm yet to be convinced otherwise.
Peter Atashian
@retep998
Nov 21 2016 23:13
Well, it's hard to invoke C++ stuff from any language that isn't C++