Skip to content

Commit abc0f94

Browse files
committed
Fix formatting and add more docs for bstr
1 parent a47f69f commit abc0f94

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

library/alloc/src/bstr.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl Default for ByteString {
231231

232232
#[unstable(feature = "bstr", issue = "134915")]
233233
impl From<ByteString> for Vec<u8> {
234-
/// Return the inner `Vec` of the byte string
234+
/// Return the inner `Vec` of the byte string.
235235
#[inline]
236236
fn from(s: ByteString) -> Self {
237237
s.0
@@ -265,6 +265,10 @@ impl From<ByteString> for Vec<u8> {
265265
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
266266
#[unstable(feature = "bstr", issue = "134915")]
267267
impl<'a> From<&'a ByteStr> for ByteString {
268+
/// Convert the `ByteStr` to a `Vec` then wrap it in a `ByteString`.
269+
///
270+
/// ## Cost
271+
/// Allocates a new `Vec`
268272
#[inline]
269273
fn from(s: &'a ByteStr) -> Self {
270274
ByteString(s.0.to_vec())
@@ -274,6 +278,7 @@ impl<'a> From<&'a ByteStr> for ByteString {
274278
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
275279
#[unstable(feature = "bstr", issue = "134915")]
276280
impl<'a> From<ByteString> for Cow<'a, ByteStr> {
281+
/// Wrap `ByteString` in `Cow::Owned`.
277282
#[inline]
278283
fn from(s: ByteString) -> Self {
279284
Cow::Owned(s)
@@ -283,6 +288,7 @@ impl<'a> From<ByteString> for Cow<'a, ByteStr> {
283288
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
284289
#[unstable(feature = "bstr", issue = "134915")]
285290
impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> {
291+
/// Wrap `ByteString` as byte str in `Cow::Borrowed`.
286292
#[inline]
287293
fn from(s: &'a ByteString) -> Self {
288294
Cow::Borrowed(s.as_bytestr())
@@ -636,7 +642,7 @@ impl Clone for Box<ByteStr> {
636642
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
637643
#[unstable(feature = "bstr", issue = "134915")]
638644
impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
639-
/// Create a `Borrowed` cow from a `ByteStr`
645+
/// Create a `Borrowed` cow from a `ByteStr`.
640646
#[inline]
641647
fn from(s: &'a ByteStr) -> Self {
642648
Cow::Borrowed(s)
@@ -646,7 +652,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
646652
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
647653
#[unstable(feature = "bstr", issue = "134915")]
648654
impl From<Box<[u8]>> for Box<ByteStr> {
649-
/// Create a `Box<[u8]>` from `Box<ByteStr>`s raw
655+
/// Create a `Box<[u8]>` from `Box<ByteStr>`s raw.
650656
#[inline]
651657
fn from(s: Box<[u8]>) -> Box<ByteStr> {
652658
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -657,7 +663,7 @@ impl From<Box<[u8]>> for Box<ByteStr> {
657663
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
658664
#[unstable(feature = "bstr", issue = "134915")]
659665
impl From<Box<ByteStr>> for Box<[u8]> {
660-
/// Create a `Box<ByteStr>` from `Box<[u8]>`s raw
666+
/// Create a `Box<ByteStr>` from `Box<[u8]>`s raw.
661667
#[inline]
662668
fn from(s: Box<ByteStr>) -> Box<[u8]> {
663669
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -668,7 +674,7 @@ impl From<Box<ByteStr>> for Box<[u8]> {
668674
#[unstable(feature = "bstr", issue = "134915")]
669675
#[cfg(not(no_rc))]
670676
impl From<Rc<[u8]>> for Rc<ByteStr> {
671-
/// Create a `Rc<[u8]>` from `Rc<ByteStr>`s raw
677+
/// Create a `Rc<[u8]>` from `Rc<ByteStr>`s raw.
672678
#[inline]
673679
fn from(s: Rc<[u8]>) -> Rc<ByteStr> {
674680
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -679,7 +685,7 @@ impl From<Rc<[u8]>> for Rc<ByteStr> {
679685
#[unstable(feature = "bstr", issue = "134915")]
680686
#[cfg(not(no_rc))]
681687
impl From<Rc<ByteStr>> for Rc<[u8]> {
682-
/// Create a `Rc<ByteStr>` from `Rc<[u8]>`s raw
688+
/// Create a `Rc<ByteStr>` from `Rc<[u8]>`s raw.
683689
#[inline]
684690
fn from(s: Rc<ByteStr>) -> Rc<[u8]> {
685691
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -690,7 +696,7 @@ impl From<Rc<ByteStr>> for Rc<[u8]> {
690696
#[unstable(feature = "bstr", issue = "134915")]
691697
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
692698
impl From<Arc<[u8]>> for Arc<ByteStr> {
693-
/// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw
699+
/// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw.
694700
#[inline]
695701
fn from(s: Arc<[u8]>) -> Arc<ByteStr> {
696702
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -701,7 +707,7 @@ impl From<Arc<[u8]>> for Arc<ByteStr> {
701707
#[unstable(feature = "bstr", issue = "134915")]
702708
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
703709
impl From<Arc<ByteStr>> for Arc<[u8]> {
704-
/// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw
710+
/// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw.
705711
#[inline]
706712
fn from(s: Arc<ByteStr>) -> Arc<[u8]> {
707713
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -722,7 +728,7 @@ impl<'a> TryFrom<&'a ByteStr> for String {
722728
type Error = core::str::Utf8Error;
723729

724730
/// Convert `ByteStr`s bytes to a utf-8 `String`.
725-
///
731+
///
726732
/// # Errors
727733
/// If `ByteStr` is not valid utf-8
728734
#[inline]

library/std/src/sys/pal/windows/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ impl FileAttr {
10701070
}
10711071
}
10721072
impl From<c::WIN32_FIND_DATAW> for FileAttr {
1073-
/// Map `c::WIN32_FIND_DATAW`s fields to a `FileAttr`,
1073+
/// Map `c::WIN32_FIND_DATAW`s fields to a `FileAttr`,
10741074
/// with some conditionals for `file_size` and `reparse_tag`.
10751075
fn from(wfd: c::WIN32_FIND_DATAW) -> Self {
10761076
FileAttr {

0 commit comments

Comments
 (0)