These are chat archives for rust-lang/rust

23rd
Oct 2018
cubetastic
@cubetastic33
Oct 23 2018 04:24
I can't find examples anywhere on how I should use WindowBuilder in winit to create a window.
I tried this code:
let mut events_loop = EventsLoop::new();
let builder = winit::WindowBuilder::new();
builder.build(&events_loop).unwrap();

events_loop.run_forever(|event| {
    match event {
        Event::WindowEvent {
            event: WindowEvent::CloseRequested,
            ..
        } => ControlFlow::Break,
        _ => ControlFlow::Continue,
    }
});
But I get this error:
[winit X11 error] XError {
    description: "BadWindow (invalid Window parameter)",
    error_code: 3,
    request_code: 131,
    minor_code: 40
}
I basically want to open a fullscreen window using winit. How do I do this? (Fullscreen, not just maximized)
Michal 'vorner' Vaner
@vorner
Oct 23 2018 05:56
Hello. Has anyone managed to used the #![feature(test)] and Bencher in 2018 edition? No matter what I do, it seems to complain that test doesn't exist (either on use test::Bencher or on extern crate test). Or is test considered dead?
Zakarum
@omni-viral
Oct 23 2018 11:31
Is it safe to transmute A -> B ?
#[repr(C)]
struct A {
    foo: Foo,
    bar: *const Bar,
}

#[repr(C)]
struct B<'a> {
    foo: Foo,
    bar: &'a Bar,
}
Michal 'vorner' Vaner
@vorner
Oct 23 2018 11:39
Probably. Assuming you don't create a too long lifetime by accident.
And that bar is not null
Denis Lisov
@tanriol
Oct 23 2018 12:14
And that it does not point to the same Bar instance as some &mut Bar
Denis Lisov
@tanriol
Oct 23 2018 12:29
I'd suggest starting with Rust. What kind of embedded?
Timothy Shoaf
@timshoaf
Oct 23 2018 12:32
TBH they are very different. C++ is an OOP manually managed memory language (excepting the scope based destructors etc). Rust is based largley around its type system, functions implemented on types, and (outside of declarations of unsafe) doesn't need to do garbage collection or require you to do manual allocation. I wouldn't say they are exactly apples to oranges, but if you start with Rust, I would say it will force you into good habits that you can use as design patterns in languages like C++
Edvin Malinovskis
@nCrazed
Oct 23 2018 13:12
sure, the difference is going to be in how hard/easy it is to express certain things
Michal 'vorner' Vaner
@vorner
Oct 23 2018 14:29

@timshoaf Actually, the runtime model of Rust is like 85% same with C++. And „modern“ C++ has a lot in common with Rust (you don't touch direct allocation either, there).

In my view, there are two big differences. C++ lets you do all kinds of stuff you don't really want to do and will place a lot of stuff you can trip over in your path (like automatic type conversions). And a library is more likely to have bindings to C++ than to Rust, since Rust is younger.

Lyle Mantooth
@IslandUsurper
Oct 23 2018 14:35
At least Rust can use a library's C bindings if they exist.
Michal 'vorner' Vaner
@vorner
Oct 23 2018 14:36
Yes, it can. It's a slightly more work than from C++, though. Not that much, but still some.
tandrysyawaludin
@tandrysyawaludin
Oct 23 2018 17:13
do Rust run better on nginx or not?
Lyle Mantooth
@IslandUsurper
Oct 23 2018 17:48
@tandrysyawaludin, do you mean "better than nginx"? Because I doubt nginx runs any rust code at all.
Even then, you'd have to pick a particular webserver built with Rust to get a real answer.
tandrysyawaludin
@tandrysyawaludin
Oct 23 2018 17:51
yes @IslandUsurper
Kelly Thomas Kline
@kellytk
Oct 23 2018 21:49
How can myvec.iter().map(...) be reversed?
Sylwester Rąpała
@xoac
Oct 23 2018 21:54
@kellytk You want reverse iter()? or map()?
Kelly Thomas Kline
@kellytk
Oct 23 2018 21:55
@xoac iter()
Sylwester Rąpała
@xoac
Oct 23 2018 21:55
myvec.iter().rev().map(...)
Kelly Thomas Kline
@kellytk
Oct 23 2018 22:00
@xoac Thank you. I have to apologize for such a stupid mistake as well. I was coding while tired last night and that's the one combination of iter/map:rev/reverse I failed to try :-D