These are chat archives for rust-lang/rust

4th
Jun 2018
tandrysyawaludin
@tandrysyawaludin
Jun 04 2018 02:03
how to run query in rust?
Sylwester Rąpała
@xoac
Jun 04 2018 09:24
@tandrysyawaludin why do u mean by query? SQL query?
Rotem Yaari
@vmalloc
Jun 04 2018 15:49
Hi! Can anyone shed some light on how chrono's Local works? How is it that we can call both Local.ymd(...) and Local::now(), given that Local is a struct?
Robert Masen
@FreeMasen
Jun 04 2018 15:49
Is Local a Unit Struct?
Rotem Yaari
@vmalloc
Jun 04 2018 15:50
@FreeMasen hmmm, looks like it
Robert Masen
@FreeMasen
Jun 04 2018 15:51
so the first call in your example is creating a new instance and immediately calling .ymd() while the other is calling the static ::now() function
Rotem Yaari
@vmalloc
Jun 04 2018 15:54
Ooooh
ok. Thanks!
Tembo
@Tembocs
Jun 04 2018 17:41
Hi everyone. Is there a std way of doing signals in Rust? Is Futures addressing this?
Michal 'vorner' Vaner
@vorner
Jun 04 2018 17:48
@Tembocs There are crates for doing that. Tokio-signal is for futures, for example.
Tembo
@Tembocs
Jun 04 2018 17:53
@vorner any known plans to have signals in the std library?
Andrey Lesnikov
@ozkriff
Jun 04 2018 17:54
rust tries to keep std as minimal as possible
Tembo
@Tembocs
Jun 04 2018 17:55
@ozkriff Ok.
Sylwester Rąpała
@xoac
Jun 04 2018 21:09
Is there a nice way to get version of my package from Cargo.toml? I would like to tag my docker image with version and use this in CI
Robert Masen
@FreeMasen
Jun 04 2018 21:09
There is an env var
I can't think of the name of it off the top of my head
Sylwester Rąpała
@xoac
Jun 04 2018 21:10
but from code
I would like to get it while build docker image
Robert Masen
@FreeMasen
Jun 04 2018 21:10
Right so ::std::env::var("CARGO_VERSION")
or whatever the env var is
You mean from another config source like chef?
Sylwester Rąpała
@xoac
Jun 04 2018 21:12
It's not what I am asking. I know how to get version from rust code. But how to get after cargo build or cargo test finished?
Robert Masen
@FreeMasen
Jun 04 2018 21:12
Like from the binary?
Sylwester Rąpała
@xoac
Jun 04 2018 21:13
docker build -t my/repo:$(cargo get version from Cargo.toml) .
yes for the binary
Robert Masen
@FreeMasen
Jun 04 2018 21:14
Do you have the cargo.toml or just the binary?
Sylwester Rąpała
@xoac
Jun 04 2018 21:15
I have cargo.toml
Robert Masen
@FreeMasen
Jun 04 2018 21:16
You could either write a bash script that will loop through the lines of it and break on the version = "" line?
You could also create a cargo sub-command for parsing the version out through the toml crate?
Sylwester Rąpała
@xoac
Jun 04 2018 21:16
It's not what I was looking.

You could also create a cargo sub-command for parsing the version out through the toml crate?

Probably its a solution