Skip to content

Conversation

steveklabnik
Copy link
Contributor

When we moved over to the book, we lost this.

let string = "Hello there.";
```

Like any Rust type, string slices have an associated lifetime. A string literal
Copy link
Member

Choose a reason for hiding this comment

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

"Like any Rust reference type" maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, fixe

@nrc
Copy link
Member

nrc commented Jan 12, 2015

r? @sfackler

@steveklabnik
Copy link
Contributor Author

This has been updated now.


Like vector slices, string slices are simply a pointer plus a length. This
means that they're a 'view' into an already-allocated string, such as a
`&'static str` or a `String`.
Copy link
Member

Choose a reason for hiding this comment

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

Using &'static str here seems wrong, maybe "string literal"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is it wrong?

Copy link
Member

Choose a reason for hiding this comment

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

It just seems a bit strange since the paragraph's saying that slices are a view into an already allocated string, such as a slice, but isn't that a view into an already allocated string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it is strange because it's an edge case: a &'static str is an always-allocated thing. And I tend to refer to things by their type explicitly. But I can see that. Lemme fix it.

@sfackler
Copy link
Member

r=me with the one last nit.

@steveklabnik
Copy link
Contributor Author

@bors: r=sfackler b33dfdb rollup

@bors
Copy link
Collaborator

bors commented Jan 22, 2015

⌛ Testing commit b33dfdb with merge 1fcaec0...

@bors
Copy link
Collaborator

bors commented Jan 22, 2015

💔 Test failed - auto-mac-64-opt

When we moved over to the book, we lost this.
@steveklabnik
Copy link
Contributor Author

@bors: r=sfackler cef8295 rollup

@steveklabnik
Copy link
Contributor Author

Woo notrust isn't a thing anymore.

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jan 22, 2015
…kler

When we moved over to the book, we lost this.
bors added a commit that referenced this pull request Jan 23, 2015
@bors bors merged commit cef8295 into rust-lang:master Jan 23, 2015
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.

4 participants