File:Crust of Rust- The Drop Check.webm

Summary

Description
English: In this episode of Crust of Rust, we go over the "drop check" — another niche part of Rust that most people don't have to think about, but which rears its moderately attractive head occasionally when you use generic types in semi-weird ways. In particular, we explore how to implement a Norwegian version of Box (which is really just Box with a different name), and find that the straightforward implementation is not quite as flexible as the standard Box is due to the drop check. When we fix it, we then make it _too_ flexible, and open ourselves the type up to undefined behavior. Which, in turn, we use the drop check to fix. Towards the end, we go through a particularly interesting example at the intersection of the drop check and variance in the form of (ab)using std::iter::Empty.

0:00:00 Introduction 0:01:39 Boks: A Norwegian Box 0:04:22 Freeing a Boks 0:05:56 Dereferencing a Boks 0:09:40 Boks is too restrictive 0:26:52 Boks is not restrictive enough 0:35:35 PhantomData and may_dangle 0:36:32 What if Oisann didn't touch T? 0:37:30 Can I write PhantomData myself? 0:38:10 Boks isn't covariant! 0:43:49 Boks isn't covariant (in code)! 0:48:10 PhantomData T without holding a T 0:51:08 std::iter::Empty and variance 1:07:34 Why the Empty example compiles 1:13:40 Recap: what are all the bits? 1:15:47 Unnecessary Complexity?

You can read more about subtyping and variance in the Rustonomicon @ https://doc.rust-lang.org/nomicon/dropck.html.

Live version with chat: https://www.youtube.com/watch?v=Das3XSWo1GU
Date
Source YouTube: Crust of Rust: The Drop Check – View/save archived versions on archive.org and archive.todayCategory:Media from YouTube
Author Jon Gjengset

Licensing

This video, screenshot or audio excerpt was originally uploaded on YouTube under a CC BY license.
Their website states: "YouTube allows users to mark their videos with a Creative Commons CC BY license."
To the uploader: You must provide a link (URL) to the original file and the authorship information if available.
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
Attribution:
Jon Gjengset
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
Category:CC-BY-3.0#Crust%20of%20Rust-%20The%20Drop%20Check.webm
Category:Media from YouTube#Crust%20of%20Rust-%20The%20Drop%20Check.webm
This file, which was originally posted to an external website, has not yet been reviewed by an administrator or reviewer to confirm that the above license is valid. See Category:License review needed for further instructions.
Category:License review needed (video)#153342316 Category:Uploaded with video2commons Category:Videos of Rust (programming language)
Category:CC-BY-3.0 Category:License review needed (video) Category:Media from YouTube Category:Uploaded with video2commons Category:Videos of Rust (programming language)