@@ -3668,15 +3668,20 @@ because it's easy. And if you need precise control over when something is
3668
3668
deallocated, leaving it up to your runtime can make this difficult.
3669
3669
3670
3670
Rust chooses a different path, and that path is called ** ownership** . Any
3671
- binding that creates a resource is the ** owner** of that resource. Being an
3672
- owner gives you three privileges, with two restrictions:
3671
+ binding that creates a resource is the ** owner** of that resource.
3672
+
3673
+ Being an owner affords you some privileges:
3673
3674
3674
3675
1 . You control when that resource is deallocated.
3675
3676
2 . You may lend that resource, immutably, to as many borrowers as you'd like.
3676
- 3 . You may lend that resource, mutably, to a single borrower. ** BUT**
3677
- 4 . Once you've done so, you may not also lend it out otherwise, mutably or
3678
- immutably.
3679
- 5 . You may not lend it out mutably if you're currently lending it to someone.
3677
+ 3 . You may lend that resource, mutably, to a single borrower.
3678
+
3679
+ But it also comes with some restrictions:
3680
+
3681
+ 1 . If someone is borrowing your resource (either mutably or immutably), you may
3682
+ not mutate the resource or mutably lend it to someone.
3683
+ 2 . If someone is mutably borrowing your resource, you may not lend it out at
3684
+ all (mutably or immutably) or access it in any way.
3680
3685
3681
3686
What's up with all this 'lending' and 'borrowing'? When you allocate memory,
3682
3687
you get a pointer to that memory. This pointer allows you to manipulate said
0 commit comments