From 8739b01e18d885930ebf909a953a638351ca1a2e Mon Sep 17 00:00:00 2001 From: Daniel Franklin Date: Mon, 22 Mar 2021 23:05:47 +0000 Subject: [PATCH] Don't execute example code Making the code executable would require adding a lot of duplicated hidden lines, plus libc isn't available. --- src/send-and-sync.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/send-and-sync.md b/src/send-and-sync.md index c2d26dc..321d443 100644 --- a/src/send-and-sync.md +++ b/src/send-and-sync.md @@ -82,7 +82,7 @@ implement Send and Sync. Let's call it a `Carton`. We start by writing code to take a value allocated on the stack and transfer it to the heap. -```rust +```rust,ignore use std::mem::size_of; use std::ptr::NonNull; @@ -114,7 +114,7 @@ to access it. [`Box`][box-doc] implements [`Deref`][deref-doc] and [`DerefMut`][deref-mut-doc] so that you can access the inner value. Let's do that. -```rust +```rust,ignore use std::ops::{Deref, DerefMut}; impl Deref for Carton { @@ -153,7 +153,7 @@ safely be Send unless it shares mutable state with something else without enforcing exclusive access to it. Each `Carton` has a unique pointer, so we're good. -```rust +```rust,ignore // Safety: No one besides us has the raw pointer, so we can safely transfer the // Carton to another thread. unsafe impl Send for Carton {} @@ -166,7 +166,7 @@ write to the pointer, and the borrow checker enforces that mutable references must be exclusive, there are no soundness issues making `Carton` sync either. -```rust +```rust,ignore // Safety: Our implementation of DerefMut requires writers to mutably borrow the // Carton, so the borrow checker will only let us have references to the Carton // on multiple threads if no one has a mutable reference to the Carton.