Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 10
StringOwnership
| Type | Size | Memory Management Model | File |
|---|---|---|---|
StringOwnership | 8 bytes | None | 2.7/String.adept |
enum StringOwnership (REFERENCE, OWN, GIVEN, DONOR)
| Enum Value | Purpose | After __pass__(String) | After __assign__(*String, POD String) |
|---|---|---|---|
StringOwnership::REFERENCE | Reference String | REFERENCE | REFERENCE |
StringOwnership::OWN | Owned String | REFERENCE | REFERENCE |
StringOwnership::GIVEN | Transfer String | OWN | OWN |
StringOwnership::DONOR | Donor String | DONOR | REFERENCE |
StringOwnership is used to represent the different states that a String value can be in.
When String values are passed to functions/methods, they are converted to kind StringOwnership::REFERENCE if they are StringOwnership::OWN, so that the callee doesn't take responsibility for freeing them. If they are StringOwnership::GIVEN, then they are converted to kind StringOwnership::OWN, so that the callee now has responsibility of freeing them. When String values are donate()d, they will be converted to kind StringOwnership::DONOR, to indicate that the string has donated ownership and therefore doesn't retain information about the given value.