Skip to content

Commit

Permalink
Fixups for the reinterpret docstring (#49807)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored May 14, 2023
1 parent 4ed4195 commit 344f1f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,11 @@ unsafe_convert(::Type{T}, x::T) where {T<:Ptr} = x # to resolve ambiguity with
unsafe_convert(::Type{P}, x::Ptr) where {P<:Ptr} = convert(P, x)

"""
reinterpret(type, A)
reinterpret(type, x)
Change the type-interpretation of the binary data in the primitive type `A`
Change the type-interpretation of the binary data in the primitive value `x`
to that of the primitive type `type`.
The size of `type` has to be the same as that of the type of `A`.
The size of `type` has to be the same as that of the type of `x`.
For example, `reinterpret(Float32, UInt32(7))` interprets the 4 bytes corresponding to `UInt32(7)` as a
[`Float32`](@ref).
Expand Down
10 changes: 5 additions & 5 deletions base/reinterpretarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct ReinterpretArray{T,N,S,A<:AbstractArray{S},IsReshaped} <: AbstractArray{T

global reinterpret

"""
@doc """
reinterpret(T::DataType, A::AbstractArray)
Construct a view of the array with the same binary data as the given
Expand All @@ -38,13 +38,13 @@ struct ReinterpretArray{T,N,S,A<:AbstractArray{S},IsReshaped} <: AbstractArray{T
```jldoctest
julia> reinterpret(Float32, UInt32[1 2 3 4 5])
1×5 reinterpret(Float32, ::Matrix{UInt32}):
1.0f-45 3.0f-45 4.0f-45 6.0f-45 7.0f-45
1.0f-45 3.0f-45 4.0f-45 6.0f-45 7.0f-45
julia> reinterpret(Complex{Int}, 1:6)
3-element reinterpret(Complex{$Int}, ::UnitRange{$Int}):
1 + 2im
3 + 4im
5 + 6im
1 + 2im
3 + 4im
5 + 6im
```
"""
function reinterpret(::Type{T}, a::A) where {T,N,S,A<:AbstractArray{S, N}}
Expand Down

0 comments on commit 344f1f5

Please sign in to comment.