Skip to content

Commit d4e98f3

Browse files
authored
Update ch18-03: Raname "object safe" to "dyn compatible"cognitive-engineering-lab#291
1 parent 04b776b commit d4e98f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ch18-03-oo-design-patterns.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,11 @@ another design pattern.
357357
Another downside is that we’ve duplicated some logic. To eliminate some of the
358358
duplication, we might try to make default implementations for the
359359
`request_review` and `approve` methods on the `State` trait that return `self`;
360-
however, this would violate object safety, because the trait doesn’t know what
360+
however, this would violate dyn compatibility, because the trait doesn’t know what
361361
the concrete `self` will be exactly. We want to be able to use `State` as a
362-
trait object, so we need its methods to be object safe.
362+
trait object, so we need its methods to be compatible with trait objects–this is
363+
known as dyn compatible. In older documentation, this concept is often referred to
364+
as object safety.
363365

364366
Other duplication includes the similar implementations of the `request_review`
365367
and `approve` methods on `Post`. Both methods delegate to the implementation of

0 commit comments

Comments
 (0)