Skip to content

Commit c5aaf1f

Browse files
authored
Merge pull request swiftlang#33825 from valeriyvan/Array-fix-snippet-endianness
2 parents 05c5171 + cdba663 commit c5aaf1f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

stdlib/public/core/Array.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ extension Array {
17881788
/// and enums.
17891789
///
17901790
/// The following example copies bytes from the `byteValues` array into
1791-
/// `numbers`, an array of `Int`:
1791+
/// `numbers`, an array of `Int32`:
17921792
///
17931793
/// var numbers: [Int32] = [0, 0]
17941794
/// var byteValues: [UInt8] = [0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]
@@ -1800,6 +1800,8 @@ extension Array {
18001800
/// }
18011801
/// // numbers == [1, 2]
18021802
///
1803+
/// - Note: This example shows the behavior on a little-endian platform.
1804+
///
18031805
/// The pointer passed as an argument to `body` is valid only for the
18041806
/// lifetime of the closure. Do not escape it from the closure for later
18051807
/// use.
@@ -1837,12 +1839,14 @@ extension Array {
18371839
/// The following example copies the bytes of the `numbers` array into a
18381840
/// buffer of `UInt8`:
18391841
///
1840-
/// var numbers = [1, 2, 3]
1842+
/// var numbers: [Int32] = [1, 2, 3]
18411843
/// var byteBuffer: [UInt8] = []
18421844
/// numbers.withUnsafeBytes {
18431845
/// byteBuffer.append(contentsOf: $0)
18441846
/// }
1845-
/// // byteBuffer == [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, ...]
1847+
/// // byteBuffer == [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]
1848+
///
1849+
/// - Note: This example shows the behavior on a little-endian platform.
18461850
///
18471851
/// - Parameter body: A closure with an `UnsafeRawBufferPointer` parameter
18481852
/// that points to the contiguous storage for the array.

stdlib/public/core/ArraySlice.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ extension ArraySlice {
14291429
/// and enums.
14301430
///
14311431
/// The following example copies bytes from the `byteValues` array into
1432-
/// `numbers`, an array of `Int`:
1432+
/// `numbers`, an array of `Int32`:
14331433
///
14341434
/// var numbers: [Int32] = [0, 0]
14351435
/// var byteValues: [UInt8] = [0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]
@@ -1441,6 +1441,8 @@ extension ArraySlice {
14411441
/// }
14421442
/// // numbers == [1, 2]
14431443
///
1444+
/// - Note: This example shows the behavior on a little-endian platform.
1445+
///
14441446
/// The pointer passed as an argument to `body` is valid only for the
14451447
/// lifetime of the closure. Do not escape it from the closure for later
14461448
/// use.
@@ -1478,12 +1480,14 @@ extension ArraySlice {
14781480
/// The following example copies the bytes of the `numbers` array into a
14791481
/// buffer of `UInt8`:
14801482
///
1481-
/// var numbers = [1, 2, 3]
1483+
/// var numbers: [Int32] = [1, 2, 3]
14821484
/// var byteBuffer: [UInt8] = []
14831485
/// numbers.withUnsafeBytes {
14841486
/// byteBuffer.append(contentsOf: $0)
14851487
/// }
1486-
/// // byteBuffer == [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, ...]
1488+
/// // byteBuffer == [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]
1489+
///
1490+
/// - Note: This example shows the behavior on a little-endian platform.
14871491
///
14881492
/// - Parameter body: A closure with an `UnsafeRawBufferPointer` parameter
14891493
/// that points to the contiguous storage for the array.

stdlib/public/core/ContiguousArray.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ extension ContiguousArray {
13611361
/// and enums.
13621362
///
13631363
/// The following example copies bytes from the `byteValues` array into
1364-
/// `numbers`, an array of `Int`:
1364+
/// `numbers`, an array of `Int32`:
13651365
///
13661366
/// var numbers: [Int32] = [0, 0]
13671367
/// var byteValues: [UInt8] = [0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]
@@ -1373,6 +1373,8 @@ extension ContiguousArray {
13731373
/// }
13741374
/// // numbers == [1, 2]
13751375
///
1376+
/// - Note: This example shows the behavior on a little-endian platform.
1377+
///
13761378
/// The pointer passed as an argument to `body` is valid only for the
13771379
/// lifetime of the closure. Do not escape it from the closure for later
13781380
/// use.
@@ -1410,12 +1412,14 @@ extension ContiguousArray {
14101412
/// The following example copies the bytes of the `numbers` array into a
14111413
/// buffer of `UInt8`:
14121414
///
1413-
/// var numbers = [1, 2, 3]
1415+
/// var numbers: [Int32] = [1, 2, 3]
14141416
/// var byteBuffer: [UInt8] = []
14151417
/// numbers.withUnsafeBytes {
14161418
/// byteBuffer.append(contentsOf: $0)
14171419
/// }
1418-
/// // byteBuffer == [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, ...]
1420+
/// // byteBuffer == [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]
1421+
///
1422+
/// - Note: This example shows the behavior on a little-endian platform.
14191423
///
14201424
/// - Parameter body: A closure with an `UnsafeRawBufferPointer` parameter
14211425
/// that points to the contiguous storage for the array.

0 commit comments

Comments
 (0)