These are chat archives for rust-lang/rust

29th
Mar 2018
Andy Grove
@andygrove
Mar 29 2018 01:37
I have a question about publishing to crates.io from a project with multiple contributors
does crates.io rely on the "authors" tag in the project to authenticate who is publishing the project?
Andy Grove
@andygrove
Mar 29 2018 01:51
nm, I found the cargo owner command
Ingvar Stepanyan
@RReverser
Mar 29 2018 12:43
@blup Looks like you're collecting into a Vec of void values - is that something you really want?
Tom Cumming
@tomcumming
Mar 29 2018 12:47
is unit the same as void
that doesn't sound right
Zakarum
@omni-viral
Mar 29 2018 12:48
there is no void in rust
There is Void and !. But they are not the same as ()
Ingvar Stepanyan
@RReverser
Mar 29 2018 12:55
Void was a poor name
never is better :P
by void I mean what is void in C
kinda
Zakarum
@omni-viral
Mar 29 2018 12:55
void in C is not the same as ()
You can't have a variable of type void
Ingvar Stepanyan
@RReverser
Mar 29 2018 12:56
Can we please not go into technical intrinsics :)
It really doesn't matter for that question
Zakarum
@omni-viral
Mar 29 2018 12:56
Ok.
Andy Grove
@andygrove
Mar 29 2018 15:57
Hi. Could I get some help with macros? I know how to write macros and pass in types using ty e.g. $DT:ty but I'm strugging how to do the same with enum variants
my macro is implementing impl From<Vec<$DT>> for ArrayData {
where $DT is i32 for example
and I want to return variant ArrayData::Int32(...)
I don't know how to pass ArrayData::Int32 or Int32 into my macro
Michal 'vorner' Vaner
@vorner
Mar 29 2018 15:59
I think ident should work.
Andy Grove
@andygrove
Mar 29 2018 16:00
macro_rules! arraydata_from_primitive {
    ($DT:ty, $AT:ident) => {
        impl From<Vec<$DT>> for ArrayData {
            fn from(v: Vec<$DT>) -> Self {
                // allocate aligned memory buffer
                let len = v.len();
                let sz = mem::size_of::<$DT>();
                let buffer = allocate_aligned((len * sz) as i64).unwrap();
                // copy data from the vec into the new buffer
                $AT(unsafe {
                    let dst = mem::transmute::<*const u8, *mut libc::c_void>(buffer);
                    libc::memcpy(dst, mem::transmute::<*const $DT, *const libc::c_void>(v.as_ptr()), len * sz);
                    mem::transmute::<*const u8, *const $DT>(buffer)
                })
            }
        }

    }
}

arraydata_from_primitive!(i32, ArrayData::Int32);
arraydata_from_primitive!(i64, ArrayData::Int64);
thanks.... this complains with
error: no rules expected the token `::`
  --> src/array.rs:68:41
   |
68 | arraydata_from_primitive!(i32, ArrayData::Int32);
   |                                         ^^
Michal 'vorner' Vaner
@vorner
Mar 29 2018 16:01
Oh, I thought you wanted to pass only Int32
(and add the ArrayData inside the macro)
Andy Grove
@andygrove
Mar 29 2018 16:02
yeah ,just realized that ... thanks, that works!
Ingvar Stepanyan
@RReverser
Mar 29 2018 16:28
@andygrove you should be also able to use path instead of ident
that would include any paths including enum variants
Eugene Tolmachev
@et1975
Mar 29 2018 18:25
Anyone knows if there is an IDE with working Intellisense (on nightly toolchain)? IDEA and VSCode fail me of late :/
Ben Kimock
@saethlin
Mar 29 2018 18:27
@jirikivaari Have you looked through rust-lang/rust or anything in rust-lang-nursery for issues with the tag "good first issue"?
Andrey Lesnikov
@ozkriff
Mar 29 2018 18:29
@et1975 IDEA has the best Intellisense right now as far as i know
Eugene Tolmachev
@et1975
Mar 29 2018 18:30
Yep. Used to work, now I get nothing.
Dylan DPC
@Dylan-DPC
Mar 29 2018 18:44
Does anyone know a crate which allows me to crawl over DOM and click buttons? :P
Dylan DPC
@Dylan-DPC
Mar 29 2018 19:11
just realised I don't need it. But it will be fun if anyone wants to try implementing it :P
Andy Grove
@andygrove
Mar 29 2018 19:13
If anyone is interested in helping out an Apache project, I have a PR open for Apache Arrow to add a native Rust version (apache/arrow#1804). It is just a starting point and I would like to get this merged so others can start contributing on top of this. Since this is their first Rust contribution they are looking for a review by a Rust expert.
Mihail Malo
@qm3ster
Mar 29 2018 19:42
HENLO LULZ

If I have a

#[derive(Clone, Default)]
struct Bepis([[Cell; 9]; 9]);

How do I make it Index?

Roman Proskuryakov
@kpp
Mar 29 2018 20:57
U FINDA CRATE MATRICS LOL
CameronDiver
@CameronDiver
Mar 29 2018 22:32

Could anybody explain why I needed &* in the following code snippet? I can't work out why I'd need a deref and a ref

        let host = String::from("some-host");
        let port: u16 = 32;
        let tcp_stream = std::net::TcpStream::connect((&*host, port));

(host and port values mocked but same types)

Mihail Malo
@qm3ster
Mar 29 2018 22:33
@kpp u tokin to meee?
CameronDiver
@CameronDiver
Mar 29 2018 22:34
The docs say impl<'a> ToSocketAddrs for (&'a str, u16) but I can't tell why that's not just &host
(also happy to take this somewhere else if this isn't the place for noob qs :P)
Mihail Malo
@qm3ster
Mar 29 2018 22:35
It's a place for questions so noob that you aren't getting a response because NOBADY KNO
:information_desk_person:
CameronDiver
@CameronDiver
Mar 29 2018 22:37
hah, fun
Denis Lisov
@tanriol
Mar 29 2018 22:42
@CameronDiver host is a String, while you need a &str for the impl. The * dereferences a String into an str.
Mihail Malo
@qm3ster
Mar 29 2018 22:43
HE KNEW
:scream:
CameronDiver
@CameronDiver
Mar 29 2018 22:44
@tanriol that does make sense, thanks, but wouldn't &host also produce a &str? At least that's how I've been using it and it seemed to work :P
except for this case ofc :)
Denis Lisov
@tanriol
Mar 29 2018 22:46
&host is a &String, which in many cases can be automatically coerced to &str
CameronDiver
@CameronDiver
Mar 29 2018 22:47
Ah ok, I get it. Thanks! :D