Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update 0000-permissions.md
  • Loading branch information
DasLixou authored Feb 3, 2023
commit f5ccce79214acbe5a8ecd44d092f64f76886fa65
8 changes: 4 additions & 4 deletions text/0000-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ impl Person {
permission Age(self.age);
permission Name(self.name);

pub fn aging(&mut self permits Age) { // this function needs the permission `'Age`
pub fn aging(&mut self permits Age) { // this function needs the permission `Age`
self.age += 1;
}

pub fn rename(&mut self permits Name, new_name: String) -> String { // this function needs the permission `'Name`
pub fn rename(&mut self permits Name, new_name: String) -> String { // this function needs the permission `Name`
std::mem::replace(&mut self.name, new_name)
}
}
Expand Down Expand Up @@ -135,11 +135,11 @@ impl Hack {
permission HackA(self.one_data);
permission HackB(self.one_data); // this should throw an error: `cannot permit `self.one_data` more than once at a time second mutable borrow occurs here - Use a unique permission instead.`

pub fn 'HackA hack_a(&mut self) {
pub fn hack_a(&mut self permits HackA) {
self.one_data./*...*/
}

pub fn 'HackB hack_b(&mut self) {
pub fn hack_b(&mut self permits HackB) {
self.one_data./*...*/
}
}
Expand Down