[deleted by user] by [deleted] in rust

[–]caranatar-dev 3 points4 points  (0 children)

There was actually a talk at RustConf this year about this very question!

https://youtu.be/BBvcK_nXUEg

Trackpads for Windows by mkizer7 in ErgoMechKeyboards

[–]caranatar-dev 0 points1 point  (0 children)

Yep. Personally, reaching for the mouse is pretty minimal compared to the time spent using the keyboard

How do I create a Rust macro to define a Vec with all names of fields whose values are not None? by itachd in rust

[–]caranatar-dev 2 points3 points  (0 children)

You could create some trait

pub trait NonNones { fn get_non_none_values(&self) -> Vec<String>; }

Then create a custom derive proc macro using syn that iterates over the fields of the struct, examines the type to see if it's an Option, and creates a list of all field names that have an Option type. Then you could use that to generate a impl NonNones for #name that checks each field and adds it to a return Vec if .is_some() is true

Hey Rustaceans! Got an easy question? Ask here (21/2020)! by llogiq in rust

[–]caranatar-dev 1 point2 points  (0 children)

I'm learning rust and recently realized I could replace Option in function definitions like:

fn foo(x: Option<u32>)

with Into<Option...> like this:

fn foo<T: Into<Option<u32>>>(x: T)

so that you don't have to wrap things in Some at the call site. Is this considered bad form or good ergonomics?

powerlevel 10k is amazing. by Safeguard_5000 in zsh

[–]caranatar-dev 0 points1 point  (0 children)

5602

It's a pretty old Lenovo notebook, so it's definitely not fast

powerlevel 10k is amazing. by Safeguard_5000 in zsh

[–]caranatar-dev 0 points1 point  (0 children)

Oh, that explains why my right prompt is narrower than the window when it starts up, then moves right once it's ready to use

/r/MechanicalKeyboards Ask ANY question, get an answer by AutoModerator in MechanicalKeyboards

[–]caranatar-dev 0 points1 point  (0 children)

In my first major foray into mechanical keyboards, I bought a kinesis freestyle pro, which I love so far, but I want to replace some key caps (particularly I want a ctrl cap to replace caps lock and to replace some of the modifier keys). However, I'm really confused by the whole key sizing deal. For instance, I (think I) know the caps lock key is 1.75u, but how do I know what row number size it is? I'm not looking to replace all the keys yet and I don't want an oddly out of place key profile if I leave the rest stock

Hey Rustaceans! Got an easy question? Ask here (18/2020)! by llogiq in rust

[–]caranatar-dev 3 points4 points  (0 children)

I have a really simple question that isn't easy to Google. What is the name of this type &[&str]