Source location of e.g. `struct` definition

What’s a way to get the sourcecode location of a struct definition?

julia> which(Rational, (Int64, Int64))
(::Type{Rational})(n::T, d::T) where T<:Integer in Base at rational.jl:21

julia> which(Main, :Rational)
Base
1 Like

AFAIK there is no functionality for this yet, but you can try the constructor which may just take you to the struct if there are no outer constructors, or it will be really close for most code. Eg

@edit Rational(1, 1)

(in your example, you are after the outer constructor anyway)

Cf

https://github.com/JuliaLang/julia/issues/14356