These are chat archives for rust-lang/rust

2nd
Feb 2017
salpalvv
@salpalvv
Feb 02 2017 00:04
@pthariensflame getting a
   |
39 |         let fns: &mut [unsafe extern "stdcall" fn(u32)] = [mem::zeroed(); 1000 ];
   |                                                           ^^^^^^^^^^^^^^^^^^^^^^ expected mutable reference, found array of 1000 elements
   |
   = note: expected type `&mut [unsafe extern "stdcall" fn(u32)]`
              found type `[_; 1000]`
Alexander Ronald Altman
@pthariensflame
Feb 02 2017 00:04
Sorry, put &mut in front of the array initializer.
I forgot about that. XD
salpalvv
@salpalvv
Feb 02 2017 00:10
@pthariensflame woo, getting an S_OK! Could you expound on the com_func((&mut fns.as_mut_ptr()) as *mut _ as *mut _) syntax. I'm unsure what's going on here.
Alexander Ronald Altman
@pthariensflame
Feb 02 2017 00:12
fns is (a mutable reference to) an array of function pointers; the as_mut_ptr call transforms it into a mutable raw pointer to the first element (that is, a C-like representation of the array).
Peter Atashian
@retep998
Feb 02 2017 00:13
@salpalvv Note that if you are actually calling a method of a COM object, you can't just call it like a freestanding function
@salpalvv You'll need to define the vtable for that interface and get the appropriate method from the vtable of the object and call it with an explicit this
(or you can define the interface using RIDL! from winapi which is much more ergonomic)
Alexander Ronald Altman
@pthariensflame
Feb 02 2017 00:15
From there, we take a mutable reference again, then use two casts: the first turns an &mut *mut F into a *mut *mut F, the second turns a *mut *mut F into a *mut *mut libc::c_ulong, where F is the type of the function pointers.
But we don’t write that out because the compiler can infer half of it.
Thus the use of _.
salpalvv
@salpalvv
Feb 02 2017 00:17
@retep998 Yeah I'm using winapi. Took awhile to type out the entire interface (maybe later there could be a macro that takes in an IDL) but it's working really nicely.
@pthariensflame I will chew on that for awhile but I think I follow :bow:
Jonathan Morley
@jonathanmorley
Feb 02 2017 00:48
Hey, I could do with some guidance on best practices for this situation: I am trying to make a client in rust for a package repository (it has a JSON rest api), and would like to have it so that I can do things like client::new(URL).repository("foo").content("/bar"). I am using serde for the reprentations of the Repository and Content objects returned by the service, which works fine, but those objects have no knowledge of the client. I have made a struct like struct Item<T> { client: &Client, Item: T } and then use that for all operations requiring further calls, but it just seems clunky
Peter Atashian
@retep998
Feb 02 2017 00:56
@salpalvv To parse IDL files would likely require a procedural macro. It is something I'd be interested in some day.
Tim
@tikue
Feb 02 2017 00:56
@pthariensflame there might be extern blocks in dependencies, but none directly. What could the problem with the interaction of extern blocks and impl Trait?
Alexander Ronald Altman
@pthariensflame
Feb 02 2017 00:59
I don't know. Honestly, I was guessing that the impl Trait usage had nothing to do with it, and that there was an unfulfilled extern dependency that was merely masked by the presence of the existential.
Tim
@tikue
Feb 02 2017 00:59
ah. We ran an experiment and when removing the impl Trait the problem goes away.
Alexander Ronald Altman
@pthariensflame
Feb 02 2017 01:00
Without knowledge of the actual code and error, that's the best I can do. :/
Tim
@tikue
Feb 02 2017 01:00
I can't really file a bug though because there isn't a minimial reproduction and the user's repo is private at this point
Alexander Ronald Altman
@pthariensflame
Feb 02 2017 01:00
There's a reason impl Trait is still unstable. XD
Tim
@tikue
Feb 02 2017 01:00
I was mostly just wondering if it sounded familiar to anyone knowledgeable about open impl Trait bugs ;)
hah yes of course :)
Alexey
@KalitaAlexey
Feb 02 2017 12:59
Hi everybody.
Some of you don't know about a new extension for Visual Studio Code: https://github.com/KalitaAlexey/vscode-rust
I have opened a PR integrating RLS: KalitaAlexey/vscode-rust#56
Arthur
@Biacode
Feb 02 2017 18:02
Hey, today is Rust release date :tada:
Alexey
@KalitaAlexey
Feb 02 2017 18:03
@Biacode,
That's cool)
Pavel Meledin
@btbvoy
Feb 02 2017 18:03
there is no 1.15 published yet
Alexey
@KalitaAlexey
Feb 02 2017 18:04
@btbvoy,
But it is going to be.
Pavel Meledin
@btbvoy
Feb 02 2017 18:05
@KalitaAlexey that’s for sure :-)
Arthur
@Biacode
Feb 02 2017 19:09
Time to rustup update :tada: