These are chat archives for rust-lang/rust

30th
Jul 2018
Sam Johnson
@sam0x17
Jul 30 2018 05:43 UTC
hello all -- I'm learning rust so I can write a cross-platform nintendo joycon => keyboard/mouse adapter for my disabled husband
just thought I'd say hi -- I'm here instead of using crystal because rust windows support is actually done and there is a decent bluetooth library (seemingly)
Sylwester Rąpała
@xoac
Jul 30 2018 13:16 UTC
How to say that T should implement T * f32 with output T? T: Mul<Output = T> dosen't work?
Zakarum
@omni-viral
Jul 30 2018 13:17 UTC
T: Mul<f32, Output = T>
Mul have type parameter with default to Self.
That type parameter specifies by what type implementation can be multiplied
@tanriol yahuu.. fn aproach worked
10k lines, but it's fast
How can Ignore bad style for whole file?
When i put in top of func

[allow(bad_style)] fn ...

It doesnt work, why?
Dmitriy
@dpogretskiy
Jul 30 2018 15:02 UTC
#!
razuit
@razuit
Jul 30 2018 15:02 UTC
anyone using Rust with Visul Studio Code, willing to share his/her tasks.json ?
Dmitriy
@dpogretskiy
Jul 30 2018 15:02 UTC
@razuit i use defaults :laughing:
Zakarum
@omni-viral
Jul 30 2018 15:03 UTC
Same
Dmitriy
@dpogretskiy
Jul 30 2018 15:03 UTC
run/build, that's it
@dpogretskiy what?
Dmitriy
@dpogretskiy
Jul 30 2018 15:03 UTC
anything more complicated in console
@trsh use #![allow(bad_style)]
#! means global
# is for single expression/function
razuit
@razuit
Jul 30 2018 15:04 UTC
not sure how to configure VSCode to run the default build task
Dmitriy
@dpogretskiy
Jul 30 2018 15:04 UTC
i always existed for me, just task build
@dpogretskiy and if I want to allow only what inside a function?
Lyle Mantooth
@IslandUsurper
Jul 30 2018 15:05 UTC
@trsh, @dpogretskiy , not exactly. #[] is for the next item, #![] is for the item it's in.
razuit
@razuit
Jul 30 2018 15:05 UTC
I have F7 configured in “Keyboard Shortcuts” as keybinding for “Run Build Task”, but not sure how to make it run the default build task, without prompting me to pick between “Rust: cargo build” and “Rust: cargo check"
@IslandUsurper and if I want to allow only what inside a function?
Lyle Mantooth
@IslandUsurper
Jul 30 2018 15:06 UTC
Use #[] right before the fn.
@IslandUsurper doesnt work
Lyle Mantooth
@IslandUsurper
Jul 30 2018 15:07 UTC
@trsh, show me?
There
@IslandUsurper
Dmitriy
@dpogretskiy
Jul 30 2018 15:08 UTC
@razuit what i do is Ctrl+P -> task build
Oh no
It was unsuded var
So it's my macro problem
ghh
Lyle Mantooth
@IslandUsurper
Jul 30 2018 15:09 UTC
Ah, yeah.
razuit
@razuit
Jul 30 2018 15:10 UTC
@dpogretskiy what should Ctrl+P do?
Dmitriy
@dpogretskiy
Jul 30 2018 15:11 UTC
@razuit it's super duper command line prompt, where you can search file names || use > to look for actions, or use taskto run tasks
probably a lot more, but that i don't really do :)
razuit
@razuit
Jul 30 2018 15:12 UTC
@dpogretskiy got it, I was hoping to do it with one key
Turns out it's per scope
If I have a loop inside a fn
like for xx in ddd
I have to add #[allow(bad_style)] on top of the loop
razuit
@razuit
Jul 30 2018 15:17 UTC
@dpogretskiy managed to figure it out, so just wanted to contribute it back here. Solved it by editing tasks.json and adding the isDefault: true, like this:
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cargo",
            "label": "cargo build",
            "command": "cargo",
            "args": [
                "build"
            ],
            "problemMatcher": [
                "$rustc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
Ingvar Stepanyan
@RReverser
Jul 30 2018 15:19 UTC
@razuit FWIW VSCode can add it for you if you choose "configure default build task" in Command Palette
Same for tests
razuit
@razuit
Jul 30 2018 15:20 UTC
@RReverser awesome! great tip! thanks!
I am thinking of porting an HTTP client app (essentially it is talking to a server via a REST API and long polling) from C++ to Rust. Anyone here worked on such thing? I looked into hyper and also found out about reqwest. Any recommendations/experience or war stories?
A bit offtopic. If Want to make some code proprietary to me, do I need to include the License in every source File? Or I can only include license.txt in Root?
Ingvar Stepanyan
@RReverser
Jul 30 2018 18:14 UTC
By default if you don't include any license, all rights already belong to you
So I think you can add exact LICENSE in the root and it automatically covers every file unless otherwise stated
Ok
Ichoran
@Ichoran
Jul 30 2018 22:17 UTC
Am I right that there is no convenient way to get ISO-8601 durations into/out of serde? It serializes time::Duration as a standard derived struct, and it doesn't like chrono::Duration even with chrono's serde feature enabled.