Rust CTCFT
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: "2022-04-18" title: "Jon Gjengset" type: slidehttps://rust-lang.zulipchat.com/#narrow/stream/286036-ctcft --- # Teaching Intermediate Rust Jon Gjengset ([@jonhoo](https://twitter.com/jonhoo)) ---- ## Who am I? - I wrote [_Rust for Rustaceans_](https://rust-for-rustaceans.com/), a book intended to follow the Rust book. - I do live Rust programming [on YouTube](https://www.youtube.com/c/JonGjengset). - I maintain the Rust build tooling at AWS. ---- ## Why am I giving this talk? I've tried to teach intermediate Rust for years and I field a lot of questions from Rust developers. --- # Let's go! --- ## Where do I look things up/ask? ---- There's doc.rust-lang.org, docs.rs, [rustc dev guide](https://rustc-dev-guide.rust-lang.org/), [nomicon](https://doc.rust-lang.org/nomicon/), [cargo book](https://doc.rust-lang.org/cargo/), [macro book](https://veykril.github.io/tlborm/), [embedded book(s)](https://docs.rust-embedded.org/), [cheats.rs](https://cheats.rs/), [rust by example](https://doc.rust-lang.org/stable/rust-by-example/), [rust cookbook](https://rust-lang-nursery.github.io/rust-cookbook/), [rust patterns](https://rust-unofficial.github.io/patterns/), [rust api guidelines](https://rust-lang.github.io/api-guidelines/), [the book](https://doc.rust-lang.org/book/), StackOverflow, users.r-l.o, internals.r-l.o, Reddit, Discord(s), Twitter. (and email/DM Jon..) ---- Great to have many avenues. Very hard to navigate and discover! ---- There are some resources that try to organize this info, like [the book of rust books](https://lborb.github.io/book/), [rust learning](https://github.com/ctjhoa/rust-learning), [awesome rust](https://github.com/rust-unofficial/awesome-rust), and [awesome rust mentors](https://rustbeginners.github.io/awesome-rust-mentors/). But those are themselves hard to find. And all suffer from the "giant list" problem. Can we do better? --- ## Papercuts inhibit learning ---- "Known shortcomings" aren't too bad if you know. But they're _extremely_ confusing otherwise. Suggests your mental model is wrong _when it isn't_. **Makes people give up.** ---- ### Some examples - Closure argument types: [#41078](https://github.com/rust-lang/rust/issues/41078) - Borrow and early return: [#54663](https://github.com/rust-lang/rust/issues/54663) - FnDef vs fn: [#86654](https://github.com/rust-lang/rust/issues/86654) - Arguably also: - [Trait aliases](https://github.com/rust-lang/rust/issues/41517) - [GAT](https://github.com/rust-lang/rust/issues/44265) - [TAIT](https://github.com/rust-lang/rust/issues/63063) --- ## Choices are hard ---- Arguably fundamental, but a major stumbling block - `Rc` vs `Arc` - `Mutex` vs `RefCell` vs `Cell` - `usize` vs `isize` vs `NonZeroI32` vs .. - tokio vs async-std vs smol vs glommio vs .. - anyhow vs thiserror vs eyre vs miette vs .. - clap vs pico-args vs argh vs gumdrop vs .. - chrono vs time - regex vs ??? - rand vs ??? ---- Can, to some extent, be fixed with docs that explicitly show differences (tables are nice). Can we encourage that somehow? ---- How do we teach "how to choose"? --- ## Cargo is a growing concern ---- As Rust gets better, Cargo pains become more visible. Sometimes known limitations or poor diagnostics. Often simply lack of knowledge! ---- No one reads the Cargo book. Few even know it exists. ---- ### Some examples - Feature merging (no mutual exclusion) - Build scripts esp. with native dependencies - `cc`? `pkg_config`? - `git submodule`? Vendor? - Intra-workspace dependencies - `default-features = false` - How rustflags are (and aren't) propagated ---- Diagnostics could help with many of these. Clippy for Cargo! --- ## unsafe remains unclear ---- Everyone is either too scared, or not scared enough. ---- Constantly changing ground (e.g., strict provenance). The rules are under- or undocumented. [Unsafe Code Guidelines WG](https://rust-lang.github.io/unsafe-code-guidelines/) progress is slow. ---- Established conventions might help. Always `/// # Safety` and `// safety:`. Can we formalize as part of the language? ---- Miri is great, but 1. analysis is limited without `-Z` flags 2. only checks the tests you wrote 3. nightly-only is a problem ---- Should work hard to stabilize unsafe-removing fns. (e.g., `[T; N]::each_mut`) --- ## Quick-fire round ---- ### Survey should ask what's hard We need _data_. Ask what users do not understand or _later realized they misunderstood_. ---- ### What is a breaking change? Not centrally documented, just lots of RFC. (esp. [private dependencies](https://github.com/rust-lang/rust/issues/44663)) ---- ### Docs should explain _why_ Developers don't "believe" necessity claims. Must _show_ why `Send`/`Sync`/`'static`/etc. matter. Give _concrete counter-examples_. Does anyone read `--explain`? Can they be repeated in docs? ---- ### Procedural macro docs are lacking Need end-to-end examples. ---- ### Ecosystem-wide search (e.g., https://www.rdocumentation.org/) ---- ### Understanding slow builds `--timings` is great, but incomplete (e.g., which proc macros, time spent linking) ---- ### Unstable feature status Tracking issues should say what's blocking. --- ## Conclusion Resources need organizing. Papercuts need fixing. Choices need comparisons. Cargo needs love. unsafe needs rules. --- ## See also https://www.reddit.com/r/rust/comments/rjjwpd/uncovered_intermediate_topics/

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully