Educational Rust live coding - Building a git CLI

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 พ.ย. 2024

ความคิดเห็น • 44

  • @jRsqILVOY
    @jRsqILVOY 4 ปีที่แล้ว +9

    The demonstration of thiserror was great!

  • @dimitardimitrov3421
    @dimitardimitrov3421 ปีที่แล้ว

    Fantastic stream. You’re a great educator! I hope you get the time for more of those!

  • @Dishankjindal
    @Dishankjindal 4 ปีที่แล้ว

    1:06:00 The way you explained the string. I am your fan now. Will love to watch a more real-world stream rust use case scenario. How about stream on FFI, take python for an instance using rust binary to handle excel sheet parsing or what not! It will definitely help clear up the concept of using rust properly. or Embedded, SoC use case stuff as well.
    What made me stop the recorded stream in between and come here comment was, the way you are taking everyone's query between stream, and on the basis of importance you take enough time to clear the doubt of the viewer. That was just heartfelt. Keep doing this.
    PS:- I read 10 chapters of the rust book it definitely helped to get familiar with the basic concepts.

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว +1

      Really happy to hear 😊 I'm glad that I could help flatten the Rust learning curve just a bit for you.
      I'm always looking for new topics and I'll make sure to add those to the list. Unfortunately I'm mostly experience with web development (mainly backend). Thats why I'm currently doing a series where I build a Twitter clone from scratch. The videos of that are also on this channel in case you're interested.
      I have very little experience with embedded stuff and only with Ruby+Rust, not Python. Parsing in general is something I would like to dive more into. Processing large amounts of data sounds like a good fit for Rust.
      Let me know if you have any other questions you want me to cover. You're also welcome to join the live streams on twitch.tv/davidpdrsn and ask questions during the stream.

  • @SimGunther
    @SimGunther 4 ปีที่แล้ว +7

    Video starts at 5:05

  • @zeusdeux
    @zeusdeux 4 ปีที่แล้ว +1

    This is wonderfully helpful and I’m only an hour in. Thank you!

  • @romanstingler435
    @romanstingler435 ปีที่แล้ว

    I wish you had more time, your coding sessions are great

  • @1vader
    @1vader 4 ปีที่แล้ว +1

    39:10 Actually stdin can and will run out of input when it is closed and/or reads EOF (end-of-file). This can happen for example when the input is piped into the program or if you press Ctrl-D on the terminal (which will send EOF). If you unwrap on the iterator this will cause a panic. I use Ctrl-D all the time to exit interactive CLI tools.
    There is also another use for Ctrl-D in non-raw mode: If you enter some text before pressing Ctrl-D it will not send EOF but instead flush the terminal buffer and pass the entered text to the application similar to entering a newline (but without the newline character at the end).

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว

      Oh yeah thats true. I didn't consider stdin being something else than the keyboard. Makes sense! I guess this bit will then go into an infinite loop if there is no more input left github.com/davidpdrsn/delete-git-branches/blob/master/src/main.rs#L107 🤔 Should probably fix that if it is the case.

  • @shashanksharma21
    @shashanksharma21 4 ปีที่แล้ว +1

    Thank you for the stream ! Learnt a ton !

  • @DavidLopez-tf4bn
    @DavidLopez-tf4bn 3 ปีที่แล้ว

    Thank you so much for doing this kinda videos, this is super helpful!

  • @MonkeeSage
    @MonkeeSage 4 ปีที่แล้ว

    3:13:09 I think you could use a label there on the for loop to continue to the label like a goto...like 'outer: for... continue 'outer

  • @lauh8406
    @lauh8406 4 ปีที่แล้ว

    Great stream. Definitely learned some good tricks.
    At 2:28:24 I think you could have actually used filter_map, but you were returning Result whereas filter_map should output Option, so by returning Option I think it would have compiled.
    Also if you delete the last branch in the loop you don't get a chance to undo with your current implementation, do you?
    Again thanks for a great stream from a fellow Dane :)

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว

      Possibly, but I'm not sure we'd easily be able to use `?` within filter_map 🤔
      And yes that is totally true, you cannot undo deleting the last branch. Didn't consider that case. PRs are welcome 😜
      🇩🇰✌️

  • @MrTact67
    @MrTact67 4 ปีที่แล้ว +2

    The reason you couldn’t delete master is that it was the branch you currently had checked out. The right thing to do there was to check whether the branch equaled repo.head().

    • @MrTact67
      @MrTact67 4 ปีที่แล้ว +2

      And I just needed to watch for five more minutes.

  • @ZhanhuiLi
    @ZhanhuiLi 2 ปีที่แล้ว

    It's helpful...Like it.

  • @misana77
    @misana77 4 ปีที่แล้ว

    Rust: has 2 types for strings.
    Same time C++: const char*, std::string, std::string_view

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว

      It actually has way more than two. Cstring, cstr, ostring, ostr, to name a few 😅

  • @MK-fd3gz
    @MK-fd3gz 4 ปีที่แล้ว

    Great video - it was very informative.
    With using recursion on the act_on_branch, would someone continuously using 'undo' eventually blow the stack ?

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว

      In theory yes, but in practice no. First of all the rust compiler (or llvm) might optimise away the recursion and just make a loop instead otherwise you would have to undo more times than you have stack space. I think it would be premature optimisation to worry too much about it.

    • @RobertElliotPahel-Short
      @RobertElliotPahel-Short 4 ปีที่แล้ว

      Thanks for explaining the '?' operator! I was wondering the same thing about using '?' on different error types and you explained it perfectly!
      This explanation starts at 31:00 for anyone interested.

  • @ognyangenev2702
    @ognyangenev2702 4 ปีที่แล้ว

    Hi, nice video! What would be the best way to list all branches as a list menu so the user can select specific branch with the arrow keys, any library recommendation?

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว +1

      You should be able to build that with crossterm. It supports cursor events and setting colors on lines. You could probably also use the tui crate.

  • @comfortablynick1
    @comfortablynick1 4 ปีที่แล้ว +1

    Thanks for the tutorial! I'm also curious about your setup...what are you using to run rust-analyzer? I use coc.nvim but it doesn't look quite the same. Also, are you using tmux? I like your statusbar.

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว +1

      I use github.com/prabirshrestha/vim-lsp. Tried coc but didn't like all the javascript stuff that it required. I'm very happy with vim-lsp. And yes I'm running nvim inside tmux. You can find all my config here github.com/davidpdrsn/dotfiles

    • @llucare
      @llucare 3 ปีที่แล้ว

      Hi @@davidpedersen2649, I'm also enjoying your session very much. I was also much interested in your (n)vim setup as it looks much more responsive from what I use (coc-rust-analyzer). In particular having diagnostics updated while you type look really useful, and light years from the "save to update" behavior of rust-analyzer with CoC. I checked your dot files and it seems now you are using exactly that. AFAIK I was wondering if you just sacrificed responsiveness for other features (better diagnostics?) or if you find a way to make coc-rust-analyzer near the responsiveness of what you had before. Thanks!

    • @davidpedersen2649
      @davidpedersen2649  3 ปีที่แล้ว

      No I didn’t do anything special to make it faster. Sounds weird that you’re having issues. Perhaps try opening an issue on either coc or rust-analyzer.

    • @llucare
      @llucare 3 ปีที่แล้ว

      @@davidpedersen2649 strange, from all I read it is a know issue that rust analyzer can't update on the fly and you have to save to "refresh" and get the current errror. There is already one issue and it is marked as a task to make rust-analyzer the default LSP for rust: github.com/rust-analyzer/rust-analyzer/issues/6591, github.com/rust-analyzer/rust-analyzer/issues/4224. From my searches I also seen people mentioning this as a know issue (for example: www.reddit.com/r/neovim/comments/j5fev9/coc_lint_on_rust_files_only_updates_after_saving/). I couldn't find a way to make it update on the fly while I type like it happens to you in the video. Is it really working for you? Thanks!

    • @davidpedersen2649
      @davidpedersen2649  3 ปีที่แล้ว

      Not quite sure I follow you. What you’re seeing in the video is what I’m experiencing 😅 I get completions while typing and it checks for errors when I save.

  • @jRsqILVOY
    @jRsqILVOY 4 ปีที่แล้ว

    Also what are your text editor settings? It looks like gvim - but you have rust-analyzer errors in line and comment/uncomment blocks at a time?

    • @davidpedersen2649
      @davidpedersen2649  4 ปีที่แล้ว

      I neovim with rust-analyzer and github.com/prabirshrestha/vim-lsp. You can find my config here github.com/davidpdrsn/dotfiles. I'm also running tmux to split the screen and stuff. The comment plugin I use is github.com/tpope/vim-commentary

    • @jRsqILVOY
      @jRsqILVOY 4 ปีที่แล้ว

      Thanks! I'll take a look at those. I use gvim and Coc but I keep having issues where rust-analyzer fails to complete methods or provide the types.

    • @shashanksharma21
      @shashanksharma21 4 ปีที่แล้ว

      @@davidpedersen2649 does vim-lsp provide the facility for displaying the errors and warning in-line with code? or are you using a separate plugin for that? I am sorry, if this is commonplace knowledge...

    • @jRsqILVOY
      @jRsqILVOY 4 ปีที่แล้ว

      @@davidpedersen2649 Also what terminal emulator do you use btw?

  • @shashanksharma21
    @shashanksharma21 3 ปีที่แล้ว

    How do you get those warnings/errors inline? I am using nvim and coc but I cant seem to find an option to do that...

    • @davidpedersen2649
      @davidpedersen2649  3 ปีที่แล้ว

      I use coc-rust-analyzer. It should show errors inline by default.

    • @shashanksharma21
      @shashanksharma21 3 ปีที่แล้ว

      @@davidpedersen2649 I use the same however I have to move the cursor to the error indication location to view the warning/error text. Anyways, thank you creating this gem of a stream! In case you decide to do another stream in the future, can you please work on creating a utility which requires some sort of client-server stuff, wherein the server is a daemon on the same machine...

    • @davidpedersen2649
      @davidpedersen2649  3 ปีที่แล้ว

      Maybe coc changed since I made this video

    • @shashanksharma21
      @shashanksharma21 3 ปีที่แล้ว

      @@davidpedersen2649 yeah maybe. Thanks anyways !

  • @bogdanfarafonov8105
    @bogdanfarafonov8105 3 ปีที่แล้ว

    "sudo apt install libssl-dev" You're welcome;)