Skip to content
Merged
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
Fix bad references to self
  • Loading branch information
aturon committed Sep 11, 2014
commit d4e9e71127e5ecd4018101370edec01f1640ab6a
8 changes: 4 additions & 4 deletions active/0000-collections-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ impl<A: Clone> ToOwned for A {
impl Borrow for str {
type Owned = String;
fn borrow(s: &String) -> &str {
self.as_slice()
s.as_slice()
}
fn borrow_mut(s: &mut String) -> &mut str {
self.as_mut_slice()
s.as_mut_slice()
}
}

Expand All @@ -434,10 +434,10 @@ impl ToOwned for str {
impl<T> Borrow for [T] {
type Owned = Vec<T>;
fn borrow(s: &Vec<T>) -> &[T] {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s --> self (and also in borrow_mut, below)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a static function, not an instance method.

Edit: This is because many structures can implement Borrow for the same type. E.G. &String and &str are both Borrow for String as far as I can tell.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair enough then. That being said: the selfs below should probably be changed to s then 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-d Thanks, fixed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that borrow is an instance method, s should probably be changed to self.

self.as_slice()
s.as_slice()
}
fn borrow_mut(s: &mut Vec<T>) -> &mut [T] {
self.as_mut_slice()
s.as_mut_slice()
}
}

Expand Down