Skip to content

Conversation

notfatdan
Copy link

In the quiz explanation ch19-01-unsafe-rust.toml, the last question mentions that the appropriate workaround for returning a pointer to a stack-allocated variable is to use garbage collection, specifically by returning an Rc. This is misleading as Rust does not have garbage collection built into the language. Rc is a reference-counted smart pointer which manages memory through reference counting and not garbage collection. Referring to it as garbage collection can cause confusion, especially for learners who are trying to figure out the differences between Rust and garbage collected languages such as Java or Python.

Suggested Fix:

Replace the reference to garbage collection with reference counting to accurately reflect Rust's memory management model.

@willcrichton
Copy link
Collaborator

I am of the firm opinion that reference counting is a form of garbage collection, as mentioned in Chapter 4.5. I support the phrasing as-is, since GC is the general strategy for returning pointers to locally-allocated objects, with reference counting being a specific implementation strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants