These are chat archives for rust-lang/rust

31st
Jan 2018
Kelly Thomas Kline
@kellytk
Jan 31 2018 05:16
What's the flaw in the toml formatting at https://play.integer32.com/?gist=b7db76d10b820999a500a0764c91a5a1&version=stable that's generating the error on line 12?
Peter Atashian
@retep998
Jan 31 2018 06:53
@koivunej I'm not entirely sure what your use case is
Do you specifically want your program to be able to work with bash's <(cat foo) syntax?
Joonas Koivunen
@koivunej
Jan 31 2018 07:17
@retep998 yes and even more generally I'd like it to work with reading from an file descriptor in windows (as it already does in linux)
Peter Atashian
@retep998
Jan 31 2018 07:17
What do you mean by "file descriptor"?
Windows has file handles, not file descriptors, and they are per process.
Joonas Koivunen
@koivunej
Jan 31 2018 07:19
@retep998 if you run echo cat <(cat foo) you'll see something like cat /dev/fd/234 so there's your file descriptor. Yes, I understand that there are handles but since cat <(cat foo) does work under mingw or whatever I already have I am assuming that handle is made available for the outer cat process to handle somehow
Peter Atashian
@retep998
Jan 31 2018 07:20
If you have a native windows program print out the arguments passed to it, it actually looks like /proc/23860/fd/63
Joonas Koivunen
@koivunej
Jan 31 2018 07:21
hmm interesting ... so i guess i should DuplicateHandle from the parent process? thanks for checking how it looks with a native app
Peter Atashian
@retep998
Jan 31 2018 07:23
That 23860 is not the process ID of the native windows program itself, nor is it the process ID of bash
It is the process ID of the temporary bash process that is created to read from that file however
So I guess DuplicateHandle would work since you can specify the source process to be that bash process
Joonas Koivunen
@koivunej
Jan 31 2018 07:28
that does sound promising but perhaps this is the wrong way to approach. according to DuplicateHandle there is a special PROCESS_DUP_HANDLE access right requirement ... I guess I'll have to try and see. And figure out how to develop under windows..
@retep998 thanks for your clarifications and investigative work!
Peter Atashian
@retep998
Jan 31 2018 07:32
well when you call OpenProcess to get a handle to the process with the given ID, you just have to specify PROCESS_DUP_HANDLE in the access rights
Once you actually have the handle you can turn it into an fs::File using https://doc.rust-lang.org/nightly/std/os/windows/io/trait.FromRawHandle.html
Joonas Koivunen
@koivunej
Jan 31 2018 07:43
@retep998 excellent news! also thanks for the links. so the mingw bash consuming the output of cat in <(cat foo) will probably start my process with the PROCESS_DUP_HANDLE right so that the handle will be accessible
Peter Atashian
@retep998
Jan 31 2018 07:44
noooo, it's you that opens a handle to the bash process and you request the PROCESS_DUP_HANDLE right while doing so
Since you need the handle to the process that has the handle you want to duplicate
Joonas Koivunen
@koivunej
Jan 31 2018 07:48
@retep998 aah right. opening a running process does sound quite strange but I guess that is similar to ls /proc/$pid in linux ... with the benefit of getting that access right.
Peter Atashian
@retep998
Jan 31 2018 07:50
Handles are how you refer to NT objects when talking to Windows API, NT being the windows kernel. Files, processes, pipes, timers, events, and so on are all various NT objects
Joonas Koivunen
@koivunej
Jan 31 2018 07:57
@retep998 ok, thanks. to be honest I really lack on the internals of Windows OSes. do you happen to have a good resource (book, site) recommendation on the topic?
Peter Atashian
@retep998
Jan 31 2018 07:58
Michal 'vorner' Vaner
@vorner
Jan 31 2018 08:09
@RustBitcoin_twitter There are two ways. You can have #[cfg(test)] mod reverse_string_test; in your reverse_string.rs, which will bring the module in from the other file. The other (more common) is to put the bigger/integration tests into a separate folter tests (under the top level directory). These all are automagically considered tests by cargo.
Stefania Delprete
@astrastefania
Jan 31 2018 09:46
If you're interested on how Rust landed in Firefox Quantum, I gave talk in Italy about, here's the slides (in English) https://github.com/astrastefania/rust-servo-quantum-talk
Sathya Narrayanan
@sourcepirate
Jan 31 2018 16:14

How do i get both path value and call persist method on to the same object.

let tfile = NamedTempFileOptions::new()
                        .prefix("tess_")
                        .suffix(&suf[..])
                        .rand_bytes(6)
                        .create();
let namedfile : NamedTempFile = tfile.unwrap();
let path: &Path = namedfile.path(); 
let fp  = namedfile.persist(&env::temp_dir());  
              //ERROR  <- namedfile  value used here after move

Any solutions ???

Kelly Thomas Kline
@kellytk
Jan 31 2018 16:17
What's the flaw in the toml formatting at https://play.integer32.com/?gist=b7db76d10b820999a500a0764c91a5a1&version=stable that's generating the error on line 12?
Tom Cumming
@tomcumming
Jan 31 2018 16:20
@kellytk indentation on line 4, 5?
ecstatic-morse
@ecstatic-morse
Jan 31 2018 16:20
@sourcepirate add a call to to_owned after the call to path
@kellytk you need two brackets around the first line
google toml sub table
@sourcepirate currently you are borrowing data from namedfile, then attempting to move from namedfile by calling persist, which invalidates the borrowed data
Kelly Thomas Kline
@kellytk
Jan 31 2018 16:34
@tomcumming That wasn't it, AFAIK toml doesn't use significant whitespace like yaml does. @ecstatic-morse Thanks, that was the problem. Now a second error is being generated https://play.integer32.com/?gist=a1906d3d71a5637c2c32315d202ce85a&version=stable do you know why?
ecstatic-morse
@ecstatic-morse
Jan 31 2018 16:40
@kellytk It's because your toml file doesn't generate the schema that whatever application you're using expects
nimtiazm
@nimtiazm
Jan 31 2018 16:40
hi. i’ve taken a program from rust doc and it crashes everytime after a while.
can anyone take a look where is the file-handle leaking?
Sathya Narrayanan
@sourcepirate
Jan 31 2018 16:41
@ecstatic-morse Thanks
Kelly Thomas Kline
@kellytk
Jan 31 2018 16:43
@ecstatic-morse I added the structs that serde is expecting to the example https://play.integer32.com/?gist=9051ddb4027eacd0ae2c0534b47b68ba&version=stable can you see the problem?
ecstatic-morse
@ecstatic-morse
Jan 31 2018 16:44
@kellytk I think you should read the TOML readme, especially the tables part
Kelly Thomas Kline
@kellytk
Jan 31 2018 16:45
I've been reading https://github.com/toml-lang/toml @ecstatic-morse but I'm obviously somewhat confused :-)
ecstatic-morse
@ecstatic-morse
Jan 31 2018 16:46
[[foo.bar]] shouldn't be there
because it's getting the api_key field
but since your problem is TOML related, and not rust related, this isn't really the right forum
Kelly Thomas Kline
@kellytk
Jan 31 2018 16:48
That's my intent, I want potentially multiple foos blocks under the top foos like I show in https://play.integer32.com/?gist=0c63c95f4f512269ff13e2f6081b19eb&version=stable
Can you recommend a more appropriate channel?
ecstatic-morse
@ecstatic-morse
Jan 31 2018 16:50
I assume TOML has an IRC channel
Kelly Thomas Kline
@kellytk
Jan 31 2018 16:51
Thanks
Michal 'vorner' Vaner
@vorner
Jan 31 2018 20:24
Hello. Why can I create a pointer to unsized type by converting a reference, but creating null one is disallowed? https://play.rust-lang.org/?gist=2afc61db46eb903dd42f43cef2e555f4&version=stable
Denis Lisov
@tanriol
Jan 31 2018 20:28
I'd guess this question boils down to "what is a null fat pointer"
And related
Michal 'vorner' Vaner
@vorner
Jan 31 2018 20:30
One that returns is_null() → true and is UB to dereference?
Jonas Platte
@jplatte
Jan 31 2018 20:31