Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ch17-object-oriented-features Fix Typo Fo -> For #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ch17-object-oriented-features Fix Typo Fo -> For
edlongman authored Jun 7, 2024
commit 36f60c5b40f4741dceae041b8120b602f3c08061
2 changes: 1 addition & 1 deletion docs/ch17-object-oriented-features.md
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ To do this in a class based language we might define a `Component` abstract clas

At runtime, a trait object will be a pair of pointers in memory - one to the instance of a specific type that implements our trait, and another to a table of methods defined on the trait to call at runtime (similar to a v-table in C++). We create a trait object by specifying a pointer (this could be a simple reference or a smart pointer like a `Box<T>`) and the `dyn` keyword (for "dynamic"). In [chapter 19][chap19] we'll talk about the `Sized` trait, and why a pointer is required here.

Fo our GUI library, we'll create a `Draw` trait, with a single method called `draw`. Instead of storing a vector of buttons or a vector of dialogs, we'll store a vector of _trait objects_:
For our GUI library, we'll create a `Draw` trait, with a single method called `draw`. Instead of storing a vector of buttons or a vector of dialogs, we'll store a vector of _trait objects_:

```rust title="src/lib.rs"
pub trait Draw {