AernaLingus [any]

  • 0 Posts
  • 40 Comments
Joined 3 years ago
cake
Cake day: May 6th, 2022

help-circle
  • I’ll preface this by saying I’m working my way through the Rust book, too–just a bit further along–so don’t take my word as gospel.

    This exact scenario is what the ? operator was designed for: returning early with the Err if one is received[1], otherwise unpacking the Ok. As you’ve discovered, it’s a common pattern, so using the ? operator greatly cuts down on the boilerplate code. If you wanted to do the equivalent of you have here (panicking instead of returning the Err for it to potentially be handled in calling code, albeit without your custom panic messages[2]) you could achieve this with unwrap() instead of ?:

    let html_content_text = reqwest::blocking::get(&permalink).unwrap().text().unwrap();
    

    Both of these will be covered in chapter 9.

    If you want to avoid those constructs until later, the only thing I’d say is that some of the intermediate variables seem unnecessary since you can match on the function call directly:

    fn get_document(permalink: String) -> Html {
            let html_content = match reqwest::blocking::get(&permalink) {
                Ok(response) => response,
                Err(error) => panic!("There was an error making the request: {:?}", error),
            };
    
            let html_content_text = match html_content.text() {
                Ok(text) => text,
                Err(error) =>
                    panic!(
                        "There was an error getting the html text from the content of response: :{:?}",
                        error
                    ),
            };
    
            let document = Html::parse_document(&html_content_text);
    
            document
        }
    

    You could also eliminate the final let statement and just stick the parse_document call at the end, but that’s a matter of preference–I know having an intermediate variable before a return can sometimes make debugging easier.

    As for whether you should build something now or wait till you learn more–go with your gut! The most important thing is that you stay actively engaged with the material, and many people find diving into projects as soon as possible helps them learn and stay motivated. You could also use rustlings and/or Rust by Example as you go through the book, which is what I’ve been doing (specifically rustlings). It’s not as stimulating as writing a project from scratch, but it does let you write some relevant code. And if you’re not already, I highly recommend using the Brown version of the Rust Book which includes interactive quizzes sprinkled throughout. I’ve found them particularly helpful for understanding the quirks of the borrow checker, which is a topic it continues to revist throughout the book.


    1. There’s also some type coercion, but that’s beyond the scope of your question ↩︎

    2. edit: you can use expect to get the custom messages as covered in another comment–not sure how I forgot that ↩︎





  • In text form:

    Abstract

    Amid the current U.S.-China technological race, the U.S. has imposed export controls to deny China access to strategic technologies. We document that these measures prompted a broad-based decoupling of U.S. and Chinese supply chains. Once their Chinese customers are subject to export controls, U.S. suppliers are more likely to terminate relations with Chinese customers, including those not targeted by export controls. However, we find no evidence of reshoring or friend-shoring. As a result of these disruptions, affected suppliers have negative abnormal stock returns, wiping out $130 billion in market capitalization, and experience a drop in bank lending, profitability, and employment.

    Quote from conclusion

    Moreover, the benefits of U.S. export controls, namely denying China access to advanced technology, may be limited as a result of Chinese strategic behavior. Indeed, there is evidence that, following U.S. export controls, China has boosted domestic innovation and self-reliance, and increased purchases from non-U.S. firms that produce similar technology to the U.S.-made ones subject to export controls.




  • I went through a phase in my late teens/early 20s where I had major bladder shyness. There were a few times in especially high pressure situations (e.g. right after a movie or during a break in a football game) where I just stood there for 30 seconds with no results and was like “welp I guess I’m just gonna have to hold it until I get home.” I honestly don’t think I had any major psychological shift, since I was and still am majorly anxious, but thankfully it waned over time and I can now piss in peace.







  • I’ve been very happy using MyAnonamouse for ebooks and audiobooks. It’s a private tracker, but it’s easy to join with just a quick interview–much less gatekeepy than most. Just read through the rules and the requirements on the invite page and you’ll be fine. The ratio requirements are also much less onerous than most private trackers and you start out with 10 GB of free upload; see the rules for details, but pretty much just grab a few freeleech torrents to start out with, make sure to seed everything for at least 72 hours in 30 days, and you’ll be golden. Helps that ebooks and audiobooks are pretty small, so unless you start out by downloading the entire ASoIaF series or something you probably won’t blow through the initial upload credit very quickly.

    That being said, as far as I can tell there doesn’t seem to be an audiobook version of that particular book, so I think you’re out of luck there.







  • Seems like it’s not fake, per se, but the methodology is highly suspect:

    Unfortunately, there are 3 major problems with this survey done in 63 countries in 2015

    1. it was conducted differently in each country ( face to face, by phone, or via web survey) which impacts the level of honesty with which people answer the question

    2. it ignores the cultural approach to precision and shame on the way respondents answer the question (and not only how they behave).

    3. Some countries surveyed only urban people, while other surveyed both urban and rural people. Each country also surveyed different age groups.

    When asked if they AUTOMATICALLY wash their hands with water and soap after using the toilette, a Dutch man who would use street urinals like this one [link was dead–I grabbed another image and rehosted on Hexbear] just once per year and always wash his hands with soap otherwise, would most likely answer NO. While a French or an Italian would have the exact same behavior would answer YES to the same question because the notion of AUTOMATICALLY is not perceived the same way in each of those countries.

    Also, cultures that are more sensitive to guilt or shame will not have the same level of honesty when answering the question, even anonymously from behind a screen. (Even though shame and guilt will most likely also influence their actual behaviour and not only their answer to the survey, it still pollute the result of the survey)

    And that’s another major problem of the survey, as it’s has been done differently in each country. Face to face in some, by phone or on the web in others. And it’s pretty obvious that people will more often be embarrassed by saying the truth when asked face to face or by phone than anonymously from behind a screen

    More info in PDF in English about the original survey here

    Another link wich is visually easier to read but the country names are written in French (as the rest of the document) and only slides 4 and 9 are relevant for the global results.

    (reddit source)