Skip to content

Commit

Permalink
Removed the lifetime anchor on CStr::from_raw_ptr
Browse files Browse the repository at this point in the history
RFC PR rust-lang#556 is likely to get discarded.
  • Loading branch information
mzabaluev committed Jan 30, 2015
1 parent 9565b47 commit 34a8dbb
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions text/0000-c-str-deref.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,10 @@ made workable in static expressions through a compiler plugin.
In cases when an FFI function returns a pointer to a non-owned C string,
it might be preferable to wrap the returned string safely as a 'thin'
`&CStr` rather than scan it into a slice up front. To facilitate this,
conversion from a raw pointer should be added (using the
[lifetime anchor](https://github.com/rust-lang/rfcs/pull/556) convention):
conversion from a raw pointer should be added:
```rust
impl CStr {
pub unsafe fn from_raw_ptr<'a, T: ?Sized>(ptr: *const libc::c_char,
life_anchor: &'a T)
-> &'a CStr
pub unsafe fn from_raw_ptr<'a>(ptr: *const libc::c_char) -> &'a CStr
{ ... }
}
```
Expand Down

0 comments on commit 34a8dbb

Please sign in to comment.