Skip to content

Fixes example snippets in UnsafePointer.swift #31321

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

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stdlib/public/core/UnsafePointer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
/// `load(fromByteOffset:as:)` method to read values.
///
/// let rawPointer = UnsafeRawPointer(uint64Pointer)
/// fullInteger = rawPointer.load(as: UInt64.self) // OK
/// firstByte = rawPointer.load(as: UInt8.self) // OK
/// let fullInteger = rawPointer.load(as: UInt64.self) // OK
/// let firstByte = rawPointer.load(as: UInt8.self) // OK
///
/// Performing Typed Pointer Arithmetic
/// ===================================
Expand Down Expand Up @@ -260,7 +260,7 @@ public struct UnsafePointer<Pointee>: _Pointer {
/// pointer to `Int64`, then accesses a property on the signed integer.
///
/// let uint64Pointer: UnsafePointer<UInt64> = fetchValue()
/// let isNegative = uint64Pointer.withMemoryRebound(to: Int64.self) { ptr in
/// let isNegative = uint64Pointer.withMemoryRebound(to: Int64.self, capacity: 1) { ptr in
/// return ptr.pointee < 0
/// }
///
Expand Down Expand Up @@ -430,8 +430,8 @@ public struct UnsafePointer<Pointee>: _Pointer {
/// to read and write values.
///
/// let rawPointer = UnsafeMutableRawPointer(uint64Pointer)
/// fullInteger = rawPointer.load(as: UInt64.self) // OK
/// firstByte = rawPointer.load(as: UInt8.self) // OK
/// let fullInteger = rawPointer.load(as: UInt64.self) // OK
/// let firstByte = rawPointer.load(as: UInt8.self) // OK
///
/// Performing Typed Pointer Arithmetic
/// ===================================
Expand Down Expand Up @@ -911,7 +911,7 @@ public struct UnsafeMutablePointer<Pointee>: _Pointer {
/// pointer to `Int64`, then accesses a property on the signed integer.
///
/// let uint64Pointer: UnsafeMutablePointer<UInt64> = fetchValue()
/// let isNegative = uint64Pointer.withMemoryRebound(to: Int64.self) { ptr in
/// let isNegative = uint64Pointer.withMemoryRebound(to: Int64.self, capacity: 1) { ptr in
/// return ptr.pointee < 0
/// }
///
Expand Down