Skip to content

Commit

Permalink
Complete presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
toddATavail committed Nov 3, 2023
0 parents commit 962fcd1
Show file tree
Hide file tree
Showing 176 changed files with 39,115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/**/target
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/rust-presentation-2023-11-09.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[workspace]
members = [
"ownership",
"double-free",
"borrow",
"naive-borrow",
"sneaky-borrow",
"sneaky-borrow-with-lifetime",
"concurrent-arc",
"concurrent-arc-mutex",
"concurrent-rc",
"concurrent-rc-in-arc"
]
resolver = "2"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Rust: An Introduction
---------------------

An introductory presentation of the Rust programming language, primarily focused
on fostering internal interest and engagement. The focus of the Rust is memory
safety, arguably its most distinctive, novel, and powerful feature.

The presentation is made with [reveal.js](https://revealjs.com/), and is located
in [docs](/docs). The original script on which the presentation
is based is [here](/docs/doc/Rust%20Talk%202023.11.09.docx), in
Microsoft Word format. I may adapt it for Markdown if I have some spare cycles.

The other top-level directories correspond to the various functional and
(intentionally) nonfunctional code samples used as props for the presentation.
8 changes: 8 additions & 0 deletions borrow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "borrow"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
25 changes: 25 additions & 0 deletions borrow/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
struct Wrapped<T>(
T // Owner of some `T`
);

enum Either<'a, 'b, A, B> {
A(&'a A), // Immutable borrow of some `A` with lifetime 'a
B(&'b B), // Immutable borrow of some `B` with lifetime 'b
}

fn main() {
let w = Wrapped(5); // Owner of `Wrapped(5)`
let mut a = Either::A(&w); // Mutable Owner of `Either`; `w` immutably borrowed
f(&mut a); // `a` mutably borrowed, updated by call
} // `a` & `w` destroyed by end of block

fn f<'a, A>(
e: &mut Either<'a, 'a, A, A> // Mutable borrow of some `Either`
) {
*e = match e {
Either::A(a) => // `a` owns borrow of `A`
Either::B(a), // `e` becomes owner of new `Either`; `a` moved
Either::B(b) => // `a` owns borrow of `A`
Either::A(b) // `e` becomes owner of new `Either`; `b` moved
}
}
8 changes: 8 additions & 0 deletions concurrent-arc-mutex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "concurrent-arc-mutex"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
18 changes: 18 additions & 0 deletions concurrent-arc-mutex/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::sync::{Arc, Mutex, MutexGuard};
use std::thread::{JoinHandle, spawn};

fn main() {
let shared: Arc<Mutex<i32>> = Arc::new(Mutex::new(0));
let join_handles: Vec<JoinHandle<()>> = (1..=10)
.map(|_| { // Don't care about the subscript, only running 10 times
let copy = Arc::clone(&shared);
spawn(move || {
let mut guarded_value: MutexGuard<i32> = copy.lock().unwrap();
*guarded_value += 1;
})
})
.collect(); // Iterators are lazy, so must collect
// Wait for all threads to complete.
join_handles.into_iter().for_each(|h| h.join().unwrap());
println!("{}", *shared.lock().unwrap()); // Prints "10\n"
}
8 changes: 8 additions & 0 deletions concurrent-arc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "concurrent-arc"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
12 changes: 12 additions & 0 deletions concurrent-arc/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::sync::Arc;
use std::thread::spawn;

fn main() {
let shared: Arc<i32> = Arc::new(10);
let copy = Arc::clone(&shared);
let forked = spawn(move || {
println!("first thread: {}", *copy);
});
forked.join().unwrap();
println!("main thread: {}", *shared);
}
8 changes: 8 additions & 0 deletions concurrent-rc-in-arc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "concurrent-rc-in-arc"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
16 changes: 16 additions & 0 deletions concurrent-rc-in-arc/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::rc::Rc;
use std::sync::Arc;
use std::thread::spawn;

fn main() {
let shared: Arc<Rc<i32>> =
Arc::new(Rc::new(10));
let copy = Arc::clone(&shared);
let forked = spawn(move ||
{
println!("first thread: {}", **copy);
}
);
forked.join().unwrap();
println!("main thread: {}", **shared);
}
8 changes: 8 additions & 0 deletions concurrent-rc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "concurrent-rc"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
14 changes: 14 additions & 0 deletions concurrent-rc/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::rc::Rc;
use std::thread::spawn;

fn main() {
let shared: Rc<i32> = Rc::new(10);
let copy = Rc::clone(&shared);
let forked = spawn(move ||
{
println!("first thread: {}", *copy);
}
);
forked.join().unwrap();
println!("main thread: {}", *shared);
}
13 changes: 13 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.idea/
*.iml
*.iws
*.eml
out/
.DS_Store
.svn
log/*.log
tmp/**
node_modules/
.sass-cache
examples/
test/
5 changes: 5 additions & 0 deletions docs/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/test
/examples
.github
.sass-cache
gulpfile.js
19 changes: 19 additions & 0 deletions docs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (C) 2011-2023 Hakim El Hattab, http://hakim.se, and reveal.js contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
50 changes: 50 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<p align="center">
<a href="https://revealjs.com">
<img src="https://hakim-static.s3.amazonaws.com/reveal-js/logo/v1/reveal-black-text-sticker.png" alt="reveal.js" width="500">
</a>
<br><br>
<a href="https://github.com/hakimel/reveal.js/actions"><img src="https://github.com/hakimel/reveal.js/workflows/tests/badge.svg"></a>
<a href="https://slides.com/"><img src="https://s3.amazonaws.com/static.slid.es/images/slides-github-banner-320x40.png?1" alt="Slides" width="160" height="20"></a>
</p>

reveal.js is an open source HTML presentation framework. It enables anyone with a web browser to create beautiful presentations for free. Check out the live demo at [revealjs.com](https://revealjs.com/).

The framework comes with a powerful feature set including [nested slides](https://revealjs.com/vertical-slides/), [Markdown support](https://revealjs.com/markdown/), [Auto-Animate](https://revealjs.com/auto-animate/), [PDF export](https://revealjs.com/pdf-export/), [speaker notes](https://revealjs.com/speaker-view/), [LaTeX typesetting](https://revealjs.com/math/), [syntax highlighted code](https://revealjs.com/code/) and an [extensive API](https://revealjs.com/api/).

---

Want to create reveal.js presentation in a graphical editor? Try <https://slides.com>. It's made by the same people behind reveal.js.

---

### Sponsors
Hakim's open source work is supported by <a href="https://github.com/sponsors/hakimel">GitHub sponsors</a>. Special thanks to:
<div align="center">
<table>
<td align="center">
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=revealjs&utm_source=github">
<div>
<img src="https://user-images.githubusercontent.com/629429/151508669-efb4c3b3-8fe3-45eb-8e47-e9510b5f0af1.svg" width="290" alt="WorkOS">
</div>
<b>Your app, enterprise-ready.</b>
<div>
<sub>Start selling to enterprise customers with just a few lines of code. Add Single Sign-On (and more) in minutes instead of months.</sup>
</div>
</a>
</td>
</table>
</div>

---

### Getting started
- πŸš€ [Install reveal.js](https://revealjs.com/installation)
- πŸ‘€ [View the demo presentation](https://revealjs.com/demo)
- πŸ“– [Read the documentation](https://revealjs.com/markup/)
- πŸ–Œ [Try the visual editor for reveal.js at Slides.com](https://slides.com/)
- 🎬 [Watch the reveal.js video course (paid)](https://revealjs.com/course)

---
<div align="center">
MIT licensed | Copyright Β© 2011-2023 Hakim El Hattab, https://hakim.se
</div>
11 changes: 11 additions & 0 deletions docs/assets/Box.mermaid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%%{init: {"flowchart": {"htmlLabels": false}} }%%
flowchart LR
Box --&gt; Content
subgraph stack
direction BT
Box
end
subgraph heap
direction TB
Content
end
1 change: 1 addition & 0 deletions docs/assets/Box.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/Ferris Speaks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 962fcd1

Please sign in to comment.