1,156 karma · joined Jan 11, 2022 (4y ago) · 205 submissions
comment 4y ago · link · parent
How would that work? References and pointers are fundamentally different types, and the primary operation on references (`Deref`) isn't available for pointers. Any methods implemented on the struct wouldn't be able to do anything with the "reference" field, since it might actually be a pointer instead - it would be like having a `struct Foo<T>(Vec<T>);`, and then specifying `Foo<boxed T>` (imaginary syntax) if you actually want a `Box<T>` instead of a `Vec<T>`. You can't just treat a `Box` like a `Vec` (or a pointer like a reference).
> - `impl Trait` for associated types. This lets you workaround async trait functions without boxing the returned futures and also return anonymous closures from traits
You're probably already aware, but for the bystanders, that seems to be close to happening: https://github.com/rust-lang/rust/issues/63063
> - Mutability variance: e.g. write `fn index<&a>(&a self, idx: Idx) -> &a T`, instead of needing to write `fn index(&self, idx: Idx) -> &T` and `fn index_mut(&mut self, idx: Idx) -> &mut T`)
I think that's something the Keyword Generics (aka "totally not effects") Initiative[1] is looking into.
> - Built-in unit types (e.g. write `#[unit(ms)] pub struct Milliseconds(usize)`, and then you can write `128ms` => `Milliseconds(128)`)
Making sure that doesn't turn into a name collision nightmare would probably needs some work. It might also make it very hard to figure out what type you're actually dealing with just by looking at such a number. The current solution to this problem, defining an extension trait on integers, produces only moderately more verbose code, with the benefit of not requiring any additional syntax: `128.ms()`.
[1]: https://blog.rust-lang.org/inside-rust/2022/07/27/keyword-ge...
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
While Rust does move a lot of errors from runtime to compile time, there are still a lot of ways to create runtime errors (which must obviously the case if your program handles any input at all).
Rust also does not stop you from creating memory leaks; there's even the `Box::leak()` method[1] that allows you to simply leak a heap allocation.
[1]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.l...
comment 4y ago · link · parent
Heat pumps have >100% efficiency, which makes them stand way out at the top, but they're an exception rather than the rule.
comment 4y ago · link · parent
> Why not Rust? If you can use Rust, ignore Carbon.
So that's probably one reason.
[1]: https://github.com/carbon-language/carbon-lang/blob/trunk/do...
comment 4y ago · link · parent
Edit: alright, CZ, UA and RU further down the thread are the same, I just hadn't gotten to those yet. Still, absolutely unacceptable for a government design standard.
comment 4y ago · link · parent
comment 4y ago · link · parent
Instead, to sort a slice of floats, you have to explicitly specify what would happen for the non-ordinary cases; e.g. by using `.sort_by(f32::total_cmp)`, where f32::total_cmp()[2] is one possible interpretation of a total ordering of floats. This requires writing more code even for cases where it would be completely unnecessary.
[1]: https://doc.rust-lang.org/std/primitive.slice.html#method.so... [2]: https://doc.rust-lang.org/std/primitive.f32.html#method.tota...
comment 4y ago · link · parent
comment 4y ago · link · parent
I'd proceed with caution. Apparently it doesn't support Wayland, so when you run it under Wayland it offers you a "Fix it!" button that, when clicked, runs sed on some gdm system config files to revert it to X11 (nevermind that gdm is far from the only way to use Wayland): https://github.com/rustdesk/rustdesk/blob/1.1.9/src/platform.... If this is the kind of thing that's considered acceptable by the developer, I'd rather keep their products far away from my machines. A quick glance at the code also reveals an almost complete lack of comments and copious use of unexplained `unsafe`.
comment 4y ago · link · parent
January 2022
February 2022
March 2022
April 2022
May 2022
June 2022
July 2022
August 2022
September 2022
October 2022
November 2022
December 2022
to the following German: Januar 2022
Februar 2022
März 2022
März 2022
Juni 2022
Juni 2022
Juli 2022
Oktober 2022
Oktober 2022
Oktober 2022
Oktober 2022
Dezember 2022
At least it gets 7/12 right?175.
Bing translator mixes up month names in dates(bing.com ↗)
2 points · by proto_lambda · 4y ago · 2 comments
comment 4y ago · link · parent
split_array will eventually allow something like the following, which avoids any explicit indexing and will fail to compile if the sizes don't match up:
struct IVec2(i32, i32);
impl IVec2 {
fn parse(b: [u8; 8]) -> Self {
let (first, second) = b.split_array();
IVec2(i32::from_le_bytes(first),
i32::from_le_bytes(second))
}
}comment 4y ago · link · parent
Lots of people are using it (and probably more every day), but there are also some quite vocal haters. Of course it has its share of problems (availability of non-Electron clients and different servers among then), but many of them constantly improve as the ecosystem grows.
comment 4y ago · link · parent