-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Document From::from
impls
#137330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Document From::from
impls
#137330
Changes from all commits
013a044
050ad7a
10dfebd
c4a5190
e133fc7
4d83e90
44e4080
42fd425
5cddbcb
b20bd28
4cbfc84
199448b
894f270
124bcb2
858b821
59a2ea3
6891a03
84128a3
d03e4b8
750828d
464e54d
8784984
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -204,6 +204,7 @@ impl Default for ByteString { | |||||||
// | ||||||||
// #[unstable(feature = "bstr", issue = "134915")] | ||||||||
// impl From<Vec<u8>> for ByteString { | ||||||||
// /// Wrap `Vec<u8>` with a `ByteString` | ||||||||
// #[inline] | ||||||||
// fn from(s: Vec<u8>) -> Self { | ||||||||
// ByteString(s) | ||||||||
|
@@ -222,6 +223,7 @@ impl From<ByteString> for Vec<u8> { | |||||||
// | ||||||||
// #[unstable(feature = "bstr", issue = "134915")] | ||||||||
// impl<'a> From<&'a str> for ByteString { | ||||||||
// /// Allocate a new `ByteString` with a copy of the bytes in the slice. | ||||||||
// #[inline] | ||||||||
// fn from(s: &'a str) -> Self { | ||||||||
// ByteString(s.as_bytes().to_vec()) | ||||||||
|
@@ -238,6 +240,7 @@ impl From<ByteString> for Vec<u8> { | |||||||
|
||||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
impl<'a> From<&'a ByteStr> for ByteString { | ||||||||
/// Allocates a `ByteString` containing the bytes of `ByteStr`. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
#[inline] | ||||||||
fn from(s: &'a ByteStr) -> Self { | ||||||||
ByteString(s.0.to_vec()) | ||||||||
|
@@ -246,6 +249,7 @@ impl<'a> From<&'a ByteStr> for ByteString { | |||||||
|
||||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
impl<'a> From<ByteString> for Cow<'a, ByteStr> { | ||||||||
/// Wrap `ByteString` in `Cow::Owned`. | ||||||||
#[inline] | ||||||||
fn from(s: ByteString) -> Self { | ||||||||
Cow::Owned(s) | ||||||||
|
@@ -599,6 +603,7 @@ impl Clone for Box<ByteStr> { | |||||||
|
||||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> { | ||||||||
/// Wrap `ByteStr` in `Cow::Borrowed`. | ||||||||
#[inline] | ||||||||
fn from(s: &'a ByteStr) -> Self { | ||||||||
Cow::Borrowed(s) | ||||||||
|
@@ -607,6 +612,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> { | |||||||
|
||||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
impl From<Box<[u8]>> for Box<ByteStr> { | ||||||||
/// Move the bytes from `Box<ByteStr>` to `Box<[u8]>`, this does not allocate new memory. | ||||||||
TimTheBig marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
#[inline] | ||||||||
fn from(s: Box<[u8]>) -> Box<ByteStr> { | ||||||||
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. | ||||||||
|
@@ -616,6 +622,7 @@ impl From<Box<[u8]>> for Box<ByteStr> { | |||||||
|
||||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
impl From<Box<ByteStr>> for Box<[u8]> { | ||||||||
/// Convert the inner bytes of `Box<[u8]>` to `ByteStr`. | ||||||||
TimTheBig marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
#[inline] | ||||||||
fn from(s: Box<ByteStr>) -> Box<[u8]> { | ||||||||
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. | ||||||||
|
@@ -626,6 +633,7 @@ impl From<Box<ByteStr>> for Box<[u8]> { | |||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
#[cfg(not(no_rc))] | ||||||||
impl From<Rc<[u8]>> for Rc<ByteStr> { | ||||||||
/// Create an `Rc<[u8]>` from the inner bytes of `Rc<ByteStr>`. | ||||||||
TimTheBig marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
#[inline] | ||||||||
fn from(s: Rc<[u8]>) -> Rc<ByteStr> { | ||||||||
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. | ||||||||
|
@@ -636,6 +644,7 @@ impl From<Rc<[u8]>> for Rc<ByteStr> { | |||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
#[cfg(not(no_rc))] | ||||||||
impl From<Rc<ByteStr>> for Rc<[u8]> { | ||||||||
/// Create a `Rc<ByteStr>` from the bytes of `Rc<[u8]>`. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
#[inline] | ||||||||
fn from(s: Rc<ByteStr>) -> Rc<[u8]> { | ||||||||
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. | ||||||||
|
@@ -646,6 +655,7 @@ impl From<Rc<ByteStr>> for Rc<[u8]> { | |||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] | ||||||||
impl From<Arc<[u8]>> for Arc<ByteStr> { | ||||||||
/// Create an `Arc<ByteStr>` from the bytes of `Arc<[u8]>`. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
#[inline] | ||||||||
fn from(s: Arc<[u8]>) -> Arc<ByteStr> { | ||||||||
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. | ||||||||
|
@@ -656,6 +666,7 @@ impl From<Arc<[u8]>> for Arc<ByteStr> { | |||||||
#[unstable(feature = "bstr", issue = "134915")] | ||||||||
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] | ||||||||
impl From<Arc<ByteStr>> for Arc<[u8]> { | ||||||||
/// Create a `Arc<[u8]>` from the inner bytes of `Arc<ByteStr>`. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
#[inline] | ||||||||
fn from(s: Arc<ByteStr>) -> Arc<[u8]> { | ||||||||
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`. | ||||||||
|
@@ -675,6 +686,10 @@ impl_partial_eq_ord_cow!(&'a ByteStr, Cow<'a, [u8]>); | |||||||
impl<'a> TryFrom<&'a ByteStr> for String { | ||||||||
type Error = core::str::Utf8Error; | ||||||||
|
||||||||
/// Try to allocate a `ByteStr`s bytes as a UTF-8 `String`. | ||||||||
/// | ||||||||
/// # Errors | ||||||||
/// If `ByteStr` is not valid UTF-8 | ||||||||
TimTheBig marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
#[inline] | ||||||||
fn try_from(s: &'a ByteStr) -> Result<Self, Self::Error> { | ||||||||
Ok(core::str::from_utf8(&s.0)?.into()) | ||||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -373,6 +373,7 @@ impl<T: Default> Default for ReentrantLock<T> { | |||
|
||||
#[unstable(feature = "reentrant_lock", issue = "121440")] | ||||
impl<T> From<T> for ReentrantLock<T> { | ||||
/// Create a new `ReentrantLock` wrapping `T` | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
fn from(t: T) -> Self { | ||||
Self::new(t) | ||||
} | ||||
|
Uh oh!
There was an error while loading. Please reload this page.