Skip to content

Commit

Permalink
Script updates. CSS fixes for code centering.
Browse files Browse the repository at this point in the history
  • Loading branch information
toddATavail committed Nov 4, 2023
1 parent 165dfe6 commit 4a702bf
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 99 deletions.
23 changes: 7 additions & 16 deletions docs/css/theme/source/local.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,20 @@
visibility: inherit;
}

.container-vertical
.reveal pre.mermaid
{
height: 75vh;
position: relative;
line-height: 1;
box-shadow: none;
}

.vertically-centered
.row
{
margin: 0;
position: absolute;
top: 50%;
transform: translateY(-50%);
display: flex;
}

.container-horizontal
.column
{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}

.reveal pre.mermaid
{
line-height: 1;
box-shadow: none;
}
22 changes: 7 additions & 15 deletions docs/dist/theme/local.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,17 @@
visibility: inherit;
}

.container-vertical {
height: 75vh;
position: relative;
.reveal pre.mermaid {
line-height: 1;
box-shadow: none;
}

.vertically-centered {
margin: 0;
position: absolute;
top: 50%;
transform: translateY(-50%);
.row {
display: flex;
}

.container-horizontal {
width: 100%;
.column {
display: flex;
align-items: center;
justify-content: center;
}

.reveal pre.mermaid {
line-height: 1;
box-shadow: none;
}
Binary file modified docs/doc/Rust Talk 2023.11.09.docx
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/doc/Rust Talk 2023.11.09.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where it can't, the borrow checker can defer ownership tracking until runtime.
There's no escaping the borrow checker, and that's a good thing!

Ownership always accompanies introduction of a value. In other words, when code
mentions a literal or instantiates a struct or enum, some variable, formal
mentions a literal or instantiates a struct or enum, then some variable, formal
parameter, field, or temporary becomes the owner of the new value. And the owner
is responsible for the value's eventual destruction, when the owner goes out of
scope.
Expand Down
2 changes: 1 addition & 1 deletion docs/doc/Telescript 2023.11.09.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ownership tracking until runtime. There's no escaping the borrow checker, and
that's a good thing!

Ownership always accompanies introduction of a value. In other words, when code
mentions a literal or instantiates a struct or enum, some variable, formal
mentions a literal or instantiates a struct or enum, then some variable, formal
parameter, field, or temporary becomes the owner of the new value. And the owner
is responsible for the value's eventual destruction, when the owner goes out of
scope.
Expand Down
147 changes: 81 additions & 66 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ <h1>MEMORY SAFETY</h1>
the borrow checker, and that's a good thing!<br>

Ownership always accompanies introduction of a value. In other words, when code mentions a literal or
instantiates a struct or enum, some variable, formal parameter, field, or temporary becomes the owner of the
new value. And the owner is responsible for the value's eventual destruction, when the owner goes out of
scope.<br>
instantiates a struct or enum, then some variable, formal parameter, field, or temporary becomes the owner
of the new value. And the owner is responsible for the value's eventual destruction, when the owner goes out
of scope.<br>

But the owner can also delegate that responsibility, by assigning the value to another variable or field or
by giving ownership to another function or method. Whenever you see a punctuation-free type annotation on a
Expand Down Expand Up @@ -567,7 +567,7 @@ <h1>MEMORY SAFETY</h1>
<div style="margin-left: 50%">
<p>Rules of borrowing:</p>
<ul>
<li class="fragment">
<li>
<em class="rust">Either</em> there may be <span class="rust">one</span> mutable borrow</li>
<li class="fragment">
<em class="rust">Or</em> there may be <span class="rust">zero</span> or <span class="rust">many</span>
Expand Down Expand Up @@ -603,27 +603,30 @@ <h1>MEMORY SAFETY</h1>
data-auto-animate="naive-borrow"
data-background-color="#AD1210"
>
<div class="container-vertical" style="width: 50%; float: left">
<div class="vertically-centered">
<pre style="font-size: medium"><code class="language-rust" data-trim data-line-numbers data-noescape>
fn owner_dropped_while_borrowed() {
let outer_borrow: &amp;i32;
{
let inner_borrow: &amp;i32;
let owner: i32 = 10;
inner_borrow = &amp;owner;
outer_borrow = inner_borrow;
<div class="row">
<div class="column" style="width: 50%; height: auto">
<div>
<pre style="font-size: medium"><code class="language-rust" data-trim data-line-numbers data-noescape>
fn owner_dropped_while_borrowed() {
let outer_borrow: &amp;i32;
{
let inner_borrow: &amp;i32;
let owner: i32 = 10;
inner_borrow = &amp;owner;
outer_borrow = inner_borrow;
}
println!("heh, heh = {}", outer_borrow);
}
println!("heh, heh = {}", outer_borrow);
}
</code></pre>
<p>Borrower, schmorrower</p>
</code></pre>
<p>Borrower, schmorrower</p>
</div>
</div>
<img
class="column"
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
</div>
<img
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
<aside class="notes">
But does it? Does it really? What happens if I do something sneaky, like this? Here, I've nested two scopes.
Inside the inner scope is the hapless and doomed owner of the value `10`, as well as the creatively named
Expand Down Expand Up @@ -686,10 +689,11 @@ <h1>MEMORY SAFETY</h1>
data-auto-animate="sneaky-borrow"
data-background-color="#AD1210"
>
<div class="container-vertical" style="width: 50%; float: left">
<div class="vertically-centered">
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
<div class="row">
<div class="column" style="width: 50%; height: auto">
<div>
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
fn assign_through_borrow(
a: &amp;mut &amp;i32,
b: &amp;mut &amp;i32
Expand All @@ -710,15 +714,17 @@ <h1>MEMORY SAFETY</h1>
}
println!("heh, heh = {}", outer_borrow);
}
</code>
</pre>
<p>Borrower, schmorrower</p>
</code>
</pre>
<p>Borrower, schmorrower</p>
</div>
</div>
<img
class="column"
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
</div>
<img
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
<aside class="notes">
But maybe we can get even more creative, by using an intermediate function call to disguise our perfidy.
Here, we've introduced two owners, <code>outer_owner</code> and <code>inner_owner</code>, and initialized
Expand Down Expand Up @@ -797,10 +803,11 @@ <h1>MEMORY SAFETY</h1>
data-auto-animate="sneaky-borrow"
data-background-color="#AD1210"
>
<div class="container-vertical" style="width: 50%; float: left">
<div class="vertically-centered">
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
<div class="row">
<div class="column" style="width: 50%; height: auto">
<div>
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
fn annotated_assign_through_borrow&lt;
'a: 'b,
'b
Expand All @@ -824,15 +831,17 @@ <h1>MEMORY SAFETY</h1>
}
println!("heh, heh = {}", outer_borrow);
}
</code>
</pre>
<p>Borrower, schmorrower</p>
</code>
</pre>
<p>Borrower, schmorrower</p>
</div>
</div>
<img
class="column"
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
</div>
<img
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
<aside class="notes">
Okay, let's make one last ditch effort to achieve villainy, because I don't know why. We're going to add two
lifetime parameters to <code>assign_to_borrow</code>, one for each formal parameter. We'll name the
Expand Down Expand Up @@ -1116,10 +1125,11 @@ <h1>MEMORY SAFETY</h1>
data-auto-animate="concurrent-rc"
data-background-color="#AD1210"
>
<div class="container-vertical" style="width: 50%; float: left">
<div class="vertically-centered">
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
<div class="row">
<div class="column" style="width: 50%; height: auto">
<div>
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
fn main() {
let shared: Rc&lt;i32&gt; = Rc::new(10);
let copy = Rc::clone(&shared);
Expand All @@ -1131,15 +1141,17 @@ <h1>MEMORY SAFETY</h1>
forked.join().unwrap();
println!("main thread: {}", *shared);
}
</code>
</pre>
<p>Borrower, schmorrower</p>
</code>
</pre>
<p>Borrower, schmorrower</p>
</div>
</div>
<img
class="column"
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
</div>
<img
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
<aside class="notes">
You may be wondering what keeps me from using an <code>Rc</code> with multiple threads, other than a
craftsman's desire not to write bad code that breaks a product at runtime. Let's put the supervillain
Expand Down Expand Up @@ -1332,10 +1344,11 @@ <h1>MEMORY SAFETY</h1>
data-auto-animate="concurrent-rc"
data-background-color="#AD1210"
>
<div class="container-vertical" style="width: 50%; float: left">
<div class="vertically-centered">
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
<div class="row">
<div class="column" style="width: 50%; height: auto">
<div>
<pre style="font-size: medium" data-id="code">
<code class="language-rust" data-trim data-line-numbers data-noescape>
fn main() {
let shared: Arc&lt;Rc&lt;i32&gt;&gt; =
Arc::new(Rc::new(10));
Expand All @@ -1348,15 +1361,17 @@ <h1>MEMORY SAFETY</h1>
forked.join().unwrap();
println!("main thread: {}", **shared);
}
</code>
</pre>
<p>Borrower, schmorrower</p>
</code>
</pre>
<p>Borrower, schmorrower</p>
</div>
</div>
<img
class="column"
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
</div>
<img
src="assets/Snidely%20Whiplash.svg"
alt="Snidely Whiplash, trying to break Rust"
style="width: 50%; height: auto">
<aside class="notes">
Okay, let's try one more technique to cheat the compiler. Maybe we can embed an <code>Rc</code> within an
<code>Arc</code> in order to bypass Rust's borrow checker.<br>
Expand Down

0 comments on commit 4a702bf

Please sign in to comment.