- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Rust Traits and Abstraction for Reusable Functional Code — Forge College
In this lesson you will learn how to name behavior with a Rust trait and design APIs that accept both closures and concrete types without unnecessary cloning or allocation. You implement a Transform behavior, provide a blanket implementation so closures satisfy that trait, and see practical tradeoffs between generic bounds and trait-object designs.
This lesson is part of the Programming with Solana track and the Introduction to Rust for Solana course, inside the module Functional Programming in Rust and Understanding Lifetimes. It follows hands-on work with closures and higher-order functions and prepares you to add lifetime and borrow-semantics reasoning when trait objects or captured environments interact.
Topics covered
- Define a Transform trait with method fn apply(&self, i: i32) returns i32 to name a reusable behavior.
- Provide a blanket impl for any F where F: Fn(i32) returns i32 so closures implement the same trait as structs.
- Write functions that accept generic bounds T: Transform and compare them with APIs that accept Box of dyn Transform.
- Design borrow-friendly signatures that avoid cloning captured environment and decide when generics outperform trait objects for performance and code size.
- A small, compiling module demonstrating a concrete struct and a closure used interchangeably so you can cargo build and test locally.
Full playlist:
https://www.youtube.com/playlist?list=PLjAMVL3818KxgHWvN6C6shmuzzVRHdKw3
Practice these patterns and build projects at https://www.forge.college/
#Rust #Traits #FunctionalProgramming #Solana #ForgeCollege
Видео Rust Traits and Abstraction for Reusable Functional Code — Forge College канала Forge College
This lesson is part of the Programming with Solana track and the Introduction to Rust for Solana course, inside the module Functional Programming in Rust and Understanding Lifetimes. It follows hands-on work with closures and higher-order functions and prepares you to add lifetime and borrow-semantics reasoning when trait objects or captured environments interact.
Topics covered
- Define a Transform trait with method fn apply(&self, i: i32) returns i32 to name a reusable behavior.
- Provide a blanket impl for any F where F: Fn(i32) returns i32 so closures implement the same trait as structs.
- Write functions that accept generic bounds T: Transform and compare them with APIs that accept Box of dyn Transform.
- Design borrow-friendly signatures that avoid cloning captured environment and decide when generics outperform trait objects for performance and code size.
- A small, compiling module demonstrating a concrete struct and a closure used interchangeably so you can cargo build and test locally.
Full playlist:
https://www.youtube.com/playlist?list=PLjAMVL3818KxgHWvN6C6shmuzzVRHdKw3
Practice these patterns and build projects at https://www.forge.college/
#Rust #Traits #FunctionalProgramming #Solana #ForgeCollege
Видео Rust Traits and Abstraction for Reusable Functional Code — Forge College канала Forge College
avoid cloning blanket implementation blockchain education box of dyn transform closure captures fn fnmut fnonce forge college generics rust learn blockchain programming with solana reusable functional code rust closures rust for solana rust traits trait bounds trait objects traits in rust web3 tutorial
Комментарии отсутствуют
Информация о видео
6 мая 2026 г. 1:23:01
00:05:47
Другие видео канала





















