• 8 Posts
  • 54 Comments
Joined 9 months ago
cake
Cake day: December 24th, 2023

help-circle

  • Binette@lemmy.mltoScience Memes@mander.xyzSo much
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 days ago

    Imagine you have a simple function: y = 2x

    If you have two different x values (let’s say 2 and 4), there exist a y value for every number in between them.

    In this example, the y is going to be in between 4 and 8, for every x in between 2 and 4.






  • Binette@lemmy.mltoScience Memes@mander.xyzMSc Mansplaining
    link
    fedilink
    English
    arrow-up
    25
    arrow-down
    10
    ·
    14 days ago

    The comments in this posts have everything I hoped to not see again once I left reddit for Lemmy 😭

    Like I’ve been mansplined before and it wasn’t fun. And no, women are less likely to do that because of societal reasons, not genetics 😂. I’m not even sure if some of the comments come from scientists, with the amount of confusion over social/genetic causes.

    Anyways, if you think someone needs help with something, always ask. And when talking to someone, ESPECIALLY if it’s a colleague/classmate, don’t try dumbing down the conversation unless you know the person you’re talking to won’t understand it.












  • Here’s the main function

    fn main() {
        let mut main_terminal = terminal::new_terminal(caps::Capabilities::new_from_env().unwrap()).unwrap();
    
        terminal::Terminal::set_raw_mode(&mut main_terminal);
    
        App::new()
            .insert_non_send_resource(main_terminal)
            .init_resource::<TextDuration>()
            .add_systems(Startup, enter_name)
            .run();
    }
    

    And here are the function enter name and flush_sdin

    fn enter_name(duration: Res<TextDuration>, main_terminal: NonSendMut<terminal::SystemTerminal>){
        print_text(&duration, Speeds::Default, String::from("Please enter your name: "));
        flush_stdin();
        terminal::Terminal::set_cooked_mode(main_terminal.into_inner());
        let mut name = String::new();
        io::stdin().read_line(&mut name);
        print_text(&duration, Speeds::Default, String::from(format!("Hello, {}!\n", name.trim().green())));
    
    }
    
    fn flush_stdin(){
        let mut clean_buffer = [0; 4];
        let _ =io::stdin().read(&mut clean_buffer[..]);
    }
    

    When I use flush_stdin, I have to press a key before submitting the actual input

    Edit: I forgot to mention, the print_text function is just something I used to make print_typed! use different speeds and stuff. I haven’t finished the different speeds for now, but that’s not important

    
    fn print_text(duration: &Res<TextDuration>, speed: Speeds, text: String){
        match speed {
            Speeds::Default => print_typed!((duration.default), "{}", text),
            
        }
    }