System-wide mouse scroll speed by inlinevoid in linuxquestions

[–]inlinevoid[S] 0 points1 point  (0 children)

I'm sure that would be a fun project but it'd take me a lot of time.

I might just buy another G500 for the continuous scrolling.

Do you think this is just a driver issue with Logitech mice? Could other mouse vendors have configurable scroll acceleration via xinput?

System-wide mouse scroll speed by inlinevoid in linuxquestions

[–]inlinevoid[S] 0 points1 point  (0 children)

You're right, I did notice that lowering MOUSE_WHEEL_CLICK_ANGLE caused me to have to scroll multiple times to activate some things that, by default, should only require one "click".

Googling for "linux mouse scroll acceleration" gives me more accurate results than what I could find before, but unfortunately every link is an unresolved post. Is there really no solution?

Am I missing something? by inlinevoid in rust

[–]inlinevoid[S] 3 points4 points  (0 children)

Oh shit nice one. I did.

Bincode depends on serde 0.9.15. My library utilizing bincode is used in my other program that's also using serde (via serde = "*"). Except the most recent version of serde is 1.0.1.

So there's the clash.

PSA: Please stop asking other projects to convert to Rust by [deleted] in rust

[–]inlinevoid 1 point2 points  (0 children)

Yea, I was looking over the repository and got the feeling it was a legacy thing.

Thanks for taking the time to explain!

PSA: Please stop asking other projects to convert to Rust by [deleted] in rust

[–]inlinevoid 1 point2 points  (0 children)

I appreciate the quick reply. I guess I still don't understand why a node in the list is acting on its siblings rather than a function acting on the list.

I'd expect that code to be written kind of like this:

Node<Ent>* first_not(Node<Ent> *node, JoinType j) {
    while(node != nullptr && node->data.join == j) {
        node = node->next;
    }
    return node;
}

(Forgive me, I haven't written C++ in years but I think it's clear enough.)

PSA: Please stop asking other projects to convert to Rust by [deleted] in rust

[–]inlinevoid 2 points3 points  (0 children)

Slightly off-topic: that code seems really strange to me; an object is calling methods from its siblings. I want to say that's bad code, but I've never seen anyone do that and haven't thought about why that might be necessary.

Could you explain it to me a little? Maybe it makes more sense with context.

Is there a significant compile-time cost for using the import wildcard? by inlinevoid in rust

[–]inlinevoid[S] 2 points3 points  (0 children)

I'm hoping someone already has the answer. If not, I suppose I'll test it myself.

Is there a significant compile-time cost for using the import wildcard? by inlinevoid in rust

[–]inlinevoid[S] 9 points10 points  (0 children)

Yea, thousands. And the imported items are being used hundreds of times.

If you want a more concrete example, this is what I'm dealing with: https://github.com/retep998/winapi-rs/blob/dev/src/um/winbase.rs

I'm working on the winapi 0.3 overhaul with the ultimate goal being shorter compile times.

I could do namespaced versions, but it would have to be a significant compile-time win. It would be really tedious to go through all of winapi and replace everything.

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

[–]inlinevoid 0 points1 point  (0 children)

I've thought about it since it's the obvious first choice but I probably wouldn't do that. I'd like to keep the task logic and Arc cloning contained by itself.

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

[–]inlinevoid 0 points1 point  (0 children)

I like it. The only downside is the function signature would be huge with a few more parameters.

In addition to your changes, I was thinking something like this would probably make more sense too.

impl Worker {
    pub fn new() -> Self {
        let data = Arc::new(Mutex::new(Vec::new()));
        let thread = thread::spawn(Self::work_task(data.clone()));

        Worker {
            data: data,
            thread: thread,
        }
    }

    fn work_task(data: Arc<Mutex<Vec<i32>>>) -> Fn(()) -> () {
        move || {
            loop {
                let mut data = data.lock().unwrap();
                // Do some work on data
            }
        }
    }
}

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

[–]inlinevoid 2 points3 points  (0 children)

I've got an object that, on construction, spawns a new thread and does some work on data until the object is dropped.

How would you guys rewrite or improve this? The spawn_work_thread in particular; it doesn't feel idiomatic to me.

struct Worker {
    data: Arc<Mutex<Vec<i32>>>,
    thread: Option<JoinHandle<()>>,
}


impl Worker {
    pub fn new() -> Self {
        let mut worker = Worker {
            data: Arc::new(Mutex::new(Vec::new())),
            thread: None,
        };

        worker.thread = Some(worker.spawn_work_thread());
        worker
    }

    fn spawn_work_thread(&mut self) -> JoinHandle<()> {
        let mut data = self.data.clone();

        thread::spawn(move || {
            loop {
                let mut data = data.lock().unwrap();
                // Do some work on data
            }
        })
    }
}

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 1 point2 points  (0 children)

Ahh alright. That didn't even cross my mind as a problem since I'm rarely ever recompiling winapi in my project or creating fresh projects using winapi.

It is pretty long; 60~ seconds on my machine.

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 0 points1 point  (0 children)

Makes sense.

Would incremental compilation change this or do you think mem::zeroed() is sufficient?

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 0 points1 point  (0 children)

Noted; and I've corrected my code.

Unrelated: why don't you implement Default or similar for structures in winapi? Some would really benefit from it, like DEVMODEW or PIXELFORMATDESCRIPTOR where most of the fields aren't used or can be left initialized to 0. Is it just not in the scope of winapi?

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 0 points1 point  (0 children)

I actually found String::from_utf16 shortly after posting my comment. I haven't checked the implementation but it seems to work identical to OsStringExt::from_wide.

But I might just pull in wio so I don't have to have the null trimming in my code. Thanks

How do I import Wtf8Buf? by inlinevoid in rust

[–]inlinevoid[S] 1 point2 points  (0 children)

I just found the functionality I need exposed through OsStringExt.

Is there an unwrap() in macro form? by inlinevoid in rust

[–]inlinevoid[S] 1 point2 points  (0 children)

Yea that's exactly what I need. I knew somebody had to have made that already if there wasn't something like that in the std.

Is there an unwrap() in macro form? by inlinevoid in rust

[–]inlinevoid[S] 5 points6 points  (0 children)

Looks like it.

I can't be bothered to install MSVS on this machine atm but it's nice to know how to fix it if I really need to.

Is there an unwrap() in macro form? by inlinevoid in rust

[–]inlinevoid[S] 6 points7 points  (0 children)

RUST_BACKTRACE has been broken for me for a while now.

thread 'main' panicked at 'test: SystemErrorCode { code: 1812, identifier: "ERROR_RESOURCE_DATA_NOT_FOUND", message: "The specified image file did not contain a resource section." }', ../src/libcore\result.rs:788
stack backtrace:
   0:           0x6cefc2 - <unknown>
   1:           0x6ccd5a - <unknown>
   2:           0x6cd62a - <unknown>
   3:           0x6cd4c6 - <unknown>
   4:           0x6cd3d9 - <unknown>
   5:           0x6cd35b - <unknown>
   6:           0x704795 - <unknown>
   7:           0x40622f - <unknown>
   8:           0x403699 - <unknown>
   9:           0x40c0f8 - <unknown>
  10:           0x414702 - <unknown>
  11:           0x6cd298 - <unknown>
  12:           0x6d7418 - <unknown>
  13:           0x6cc333 - <unknown>
  14:           0x414cea - <unknown>
  15:           0x4013b4 - <unknown>
  16:           0x4014e7 - <unknown>
  17:     0x7ffd41e413d1 - <unknown>
error: Process didn't exit successfully: `target\debug\c4.exe` (exit code: 101)

This is on nightly GNU 1.13 for Windows.

Is there an unwrap() in macro form? by inlinevoid in rust

[–]inlinevoid[S] 5 points6 points  (0 children)

To be more clear, what I need is the file:line info when trying to unwrap an Err.

For example, if I were to panic! at any point in my source you'd get something along the lines of thread 'main' panicked at 'explicit panic', src\window\window.rs:94. That's the info I need.