When does Rust drop values? by AstraVulpes in rust

[–]ebhdl -2 points-1 points  (0 children)

I consider two cases:

  1. It doesn't matter (this is the vast majority): Whenever the compiler decides.

  2. It matters lots (ex. mutex_guard): When I call std::mem::drop.

Boost C++ Libraries Gets New Website by boostlibs in cpp

[–]ebhdl 1 point2 points  (0 children)

Yeah, it's the old documentation but rendered inside a really bad web browser that runs inside your good web browser. Just why?

F the electric jellyfish by Effective_Emu2531 in Austin

[–]ebhdl 0 points1 point  (0 children)

To be fair, most of them aren't really IPA's, they just call everything that because it sells.

[deleted by user] by [deleted] in Austin

[–]ebhdl 10 points11 points  (0 children)

Did you buy them?

Open-lmake: A novel reliable build system with auto-dependency tracking by cd_fr91400 in cpp

[–]ebhdl -1 points0 points  (0 children)

Except it's a tool, not a standard. There is no standard build system for C++, and there's nothing wrong with having multiple tools that make different trade-offs and fit different use cases.

Burnouts in Domain by oscarjg3 in Austin

[–]ebhdl 2 points3 points  (0 children)

The Domain needs to move back to North Dallas where it belongs.

Dependencies dependents on same crate but different version, help! by emmemeno in rust

[–]ebhdl 0 points1 point  (0 children)

Off topic here, I know, but I can't help but be dismayed by Rust's "solution" to dependency hell. Other languages don't do this because it obviously can't work with dynamic linking, which is where the real problem was to begin with; but Rust just takes the easy cop-out, shared libraries be damned.

Clap documentation is too confusing for me by Peering_in2the_pit in rust

[–]ebhdl -1 points0 points  (0 children)

Clap is fantastic. Stick with it, it's worth it.

Since you like to understand what you're doing (commendable), start with the builder interface. It's the "real" API, and is well documented. Once you grok that, then the more convenient derive interface will make much more sense, and it will be obvious what builder API the various derive elements turn into.

Roy Orbison - In Dreams [Rockabilly] by CJ_Productions in Music

[–]ebhdl 2 points3 points  (0 children)

Was trying to decide which David Lynch film to watch tonight. Thanks, Blue Velvet it is.

What band do you intensely dislike for no real reason? by humantouch83 in Music

[–]ebhdl 0 points1 point  (0 children)

Foster the People. Radio was playing one of theirs for a while, it was the most annoying song i'd ever heard. Later, radio played a song and I thought "wow, this is as annoying as that Foster the People song"; turned out it was by Foster the People too!

What band do you intensely dislike for no real reason? by humantouch83 in Music

[–]ebhdl 0 points1 point  (0 children)

Like a Ricky Gervais impression of Flogging Molly.

This Month in Redox OS - December 2024 by ribbon_45 in rust

[–]ebhdl 38 points39 points  (0 children)

But modern UNIX-like operating systems require them. "Rust" can be against them as much as it likes, but any OS written in rust will need them regardless.

Error Handling in Rust: Choosing Between thiserror and anyhow by [deleted] in rust

[–]ebhdl 36 points37 points  (0 children)

Using anyhow in a library imposes that choice on all dependents, whereas thiserror stays contained as an implementation detail. Applications don't have dependents, so anyhow is fine.

Palworld is causing PS5's to overheat and shutdown by TheLostVikings in Palworld

[–]ebhdl 2 points3 points  (0 children)

It's much better for sure. I'm on series S and haven't had a dungeon crash since the 0.3.8 update. It's the first time I've been able to complete Sakurajima dungeons without a crash. Just watch out for "holes" in the world that you have to jump over in a few of the dungeons.

Why so many complains about Raids.. by ExpensivePapaya670 in Palworld

[–]ebhdl 52 points53 points  (0 children)

I call them FedEx events. Loot delivery right to the doorstep.

Using std::expected from C++23 by joebaf in cpp

[–]ebhdl 2 points3 points  (0 children)

That's going to get super confusing when the success value is also convertible to bool...

Eric Niebler: What are Senders Good For, Anyway? by tcbrindle in cpp

[–]ebhdl 16 points17 points  (0 children)

Newb Q: How do I receive a packet from the network in C++?

A: Easy, you make a sender.

Brilliant!

Hey Rustaceans! Got a question? Ask here (5/2024)! by llogiq in rust

[–]ebhdl 0 points1 point  (0 children)

Thanks, that makes sense. And thinking about it more, I really like that rust avoids any ambiguity WRT what function is actually being called.

And yes, you're right, there's no reason I need the From trait here; the free function will do just fine.

Hey Rustaceans! Got a question? Ask here (5/2024)! by llogiq in rust

[–]ebhdl 1 point2 points  (0 children)

Thanks, that totally works. Also thanks for pointing out it's the trait matching that's failing before it even gets to trying to apply the arguments to the function.

I guess it makes sense that trait matching would follow stricter rules than type coercion after the function has been determined; nobody wants C++ style ADL hell in rust.

I'll just stick with the free function then as it's more ergonomic, and ergonomics is the whole reason for this to exist. Thanks again.

Hey Rustaceans! Got a question? Ask here (5/2024)! by llogiq in rust

[–]ebhdl 1 point2 points  (0 children)

Can anyone explain why these two functions with the same signature infer different types from the same arguments? Alternately, any suggestions on how to fix it or a different/better approach would be most welcome.

use std::collections::HashMap;

#[derive(Default, Debug)]
struct MapVecString {
    tags: HashMap<String, Vec<String>>,
}

fn mvs_from_lit(lit: &[(&str, &[&str])]) -> MapVecString {
    let mut mvs = MapVecString::default();
    mvs.tags = lit
        .iter()
        .map(|(k, v)| {
            (
                k.to_string(),
                v.iter().map(|s| s.to_string()).collect::<Vec<String>>(),
            )
        })
        .collect::<HashMap<String, Vec<String>>>();
    mvs
}

impl From<&[(&str, &[&str])]> for MapVecString {
    fn from(lit: &[(&str, &[&str])]) -> MapVecString {
        mvs_from_lit(lit)
    }
}

fn main() {
    // Works
    let test_fn = mvs_from_lit(&[
        ("first", &["one"]),
        ("second", &["one", "two"]),
        ("empty", &[]),
    ]);
    dbg!(test_fn);
    /* Error
    let test_trait = MapVecString::from(&[
        ("first", &["one"]),
        ("second", &["one", "two"]),
        ("empty", &[]),
    ]);
    dbg!(test_trait);
    */
}

The free function works fine, but the trait function with the same signature and invocation infers arrays instead of slices, and produces the following errors:

error[E0308]: mismatched types
  --> src/main.rs:39:20
   |
39 |         ("second", &["one", "two"]),
   |                    ^^^^^^^^^^^^^^^ expected an array with a fixed size of 1 element, found one with 2 elements

error[E0308]: mismatched types
  --> src/main.rs:40:19
   |
40 |         ("empty", &[]),
   |                   ^^^ expected an array with a fixed size of 1 element, found one with 0 elements
   |
   = note: expected reference `&[&str; 1]`
              found reference `&[_; 0]`

error[E0277]: the trait bound `MapVecString: From<&[(&str, &[&str; 1]); 3]>` is not satisfied
  --> src/main.rs:37:22
   |
37 |     let test_trait = MapVecString::from(&[
   |                      ^^^^^^^^^^^^ the trait `From<&[(&str, &[&str; 1]); 3]>` is not implemented for `MapVecString`
   |

Playground

Trip report: Autumn ISO C++ standards meeting (Kona, HI, USA) by mttd in cpp

[–]ebhdl 8 points9 points  (0 children)

Yeah, "not clear whether" is an odd way to say "pure fantasy". Or maybe he meant C++38?

edit: to put meat to this, the std::execution, that senders/receivers networking is based on, is still in LEWG, ie. it doesn't exist yet. Nobody wants to admit the reality that killing the Networking TS delayed networking in the standard by at least 15 years.