Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

A Firehose of Rust, for busy people who know some C++

Автор: Jack O'Connor

Загружено: 2021-06-01

Просмотров: 95803

Описание:

Slides: https://jacko.io/firehose_of_rust
The slower version of this talk (2h32m):    • [SLOWER VERSION] A Firehose of Rust, for b...  

Contents:
0:00:00 introduction
0:04:03 references and mutable aliasing
0:06:54 reference lifetime examples
0:22:12 mutable aliasing examples
0:50:16 move semantics
1:10:50 Arc Mutex String
1:23:28 outro

Links from screenshots in slides:
https://godbolt.org/z/891s6z4Tb
   • CppCon 2014: Herb Sutter "Back to the Basi...  
https://godbolt.org/z/fK1WchMYf
   • CppCon 2017: Louis Brandy “Curiously Recur...  

Errata:
The example raw pointer code shown at 26:33 is valid today according to Miri, but it's not the best approach, and it's possible that it will become invalid before the rules for unsafe Rust finally stabilize. The worry is that creating a temporary shared reference on line 3 implies that the mutable reference on line 2 is definitely dead, which could mean that the raw pointer on line 2 is also dead in some sense. A more conservative approach would be to use .as_mut_ptr() to get a pointer to the first element and then .add() to get a pointer to the second element, without creating any extra references to the array. (Update: The "Tree Borrows" model for Miri also allows the example as written. https://perso.crans.org/vanille/treebor/)
At 56:20 I described both C++ copy constructors and the Rust .clone() method as making a "deep copy". That's sometimes the right way to think about it, but not when pointers and references get involved. Indeed, the final section relies on shallow cloning to share a reference-counted object across threads. C++ and Rust behave very similarly here, and understanding that ".clone() works like a C++ copy constructor" tells you most of what you need to know about a wide variety of different types.
At 1:05:49 I said that Mutex in Rust needs a heap allocation on Linux because of how the underlying system calls work. That's mostly incorrect. It's true that a futex can't be moved while locked, and that does matter for std::mutex in C++. But it doesn't actually matter in Rust, because a Mutex is borrowed and immovable while it's locked. Instead, the issue in Rust is that POSIX doesn't guarantee that a pthread_mutex_t is movable (although many implementations are movable in practice). See   / 1403413967846977538  . (Update: As of Rust 1.62, released in June 2022, Mutex on Linux creates a futex directly and no longer needs a heap allocation. Mutex still uses pthreads and heap allocation on some other Unix systems.)
At 1:15:13 I use Arc+Mutex to get the multithreaded Rust example working. That's a common idiom in Rust, and it's good to demo it, but as of Rust 1.63 (August 2022) you can also use "scoped" threads: https://doc.rust-lang.org/std/thread/...

A Firehose of Rust, for busy people who know some C++

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Unsafe Rust is not C

Unsafe Rust is not C

[SLOWER VERSION] A Firehose of Rust, for busy people who know some C++

[SLOWER VERSION] A Firehose of Rust, for busy people who know some C++

From Rust to C and Back Again: an introduction to

From Rust to C and Back Again: an introduction to "foreign functions"

The Downsides Of C++ | Prime Reacts

The Downsides Of C++ | Prime Reacts

Ladybird On Swift vs Rust

Ladybird On Swift vs Rust

Visualizing memory layout of Rust's data types

Visualizing memory layout of Rust's data types

A First Look at Lifetimes in Rust

A First Look at Lifetimes in Rust

Rust vs  C++ with Steve Klabnik and Herb Sutter

Rust vs C++ with Steve Klabnik and Herb Sutter

Prime Reacts: от C к C++, от Rust к Haskell

Prime Reacts: от C к C++, от Rust к Haskell

Чему я научился, решив 50 задач из Advent of Code на Rust — Лучано Маммино

Чему я научился, решив 50 задач из Advent of Code на Rust — Лучано Маммино

Zig is better than Rust (sometimes)

Zig is better than Rust (sometimes)

Rust for C++ developers - What you need to know to get rolling with crates - Pavel Yosifovich

Rust for C++ developers - What you need to know to get rolling with crates - Pavel Yosifovich

but what is 'a lifetime?

but what is 'a lifetime?

Введение в асинхронное выполнение функций Rust с помощью Smol 🦀 Учебник по программированию на Ru...

Введение в асинхронное выполнение функций Rust с помощью Smol 🦀 Учебник по программированию на Ru...

Impl Trait aka Look ma’, no generics! by Jon Gjengset

Impl Trait aka Look ma’, no generics! by Jon Gjengset

Rust can Compete with Python

Rust can Compete with Python

C++ RVO: Return Value Optimization for Performance in Bloomberg C++ Codebases - Michelle Fae D'Souza

C++ RVO: Return Value Optimization for Performance in Bloomberg C++ Codebases - Michelle Fae D'Souza

Принц Персии: разбираем код гениальной игры, вытирая слезы счастья

Принц Персии: разбираем код гениальной игры, вытирая слезы счастья

Почему я не люблю ржавчину

Почему я не люблю ржавчину

C++11 to C++23 in the C++ Memory Model - Alex Dathskovsky - C++Now 2024

C++11 to C++23 in the C++ Memory Model - Alex Dathskovsky - C++Now 2024

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]