Skip to content

Commit 22e07c2

Browse files
Document the explicit FunctionWrappersWrapper{FW, P, CS}(fw, cs) constructor
`FunctionWrappersWrapper` is exported, so its inner constructor was already reachable as public API, but it carried no docstring — the only constructor of the type that did not. Downstream solver stacks construct through exactly this method, because supplying `FW`, `P` and `CS` directly keeps the wrapper type inferrable without relying on constant propagation through a keyword-argument frame, which the `argtypes`/`rettypes` and tuple constructors do. The docstring is attached with `@doc` on the method signature after the struct; a docstring written inside the struct body does not attach to the type's binding, so Documenter would never render it. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent a552d4d commit 22e07c2

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/FunctionWrappersWrappers.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,50 @@ struct FunctionWrappersWrapper{FW, P, CS}
222222
end
223223
end
224224

225+
@doc """
226+
FunctionWrappersWrapper{FW, P, CS}(fw, cs) -> FunctionWrappersWrapper{FW, P, CS}
227+
228+
Create a `FunctionWrappersWrapper` from an already-built wrapper tuple and cache storage,
229+
with every type parameter fixed by the caller.
230+
231+
This is the fully explicit form. Prefer it when the result type must be inferrable from
232+
type parameters alone: `FW`, `P` and `CS` are given directly rather than derived from
233+
argument values, so nothing rests on constant propagation through a keyword-argument
234+
frame. Solver stacks that wrap a type-erased callable — where the wrapper type, and every
235+
cache built from it, must stay concrete — construct through this method.
236+
237+
The caller is responsible for consistency: `fw` must match `FW`, and `cs` must be the
238+
storage type `P`'s fallback path expects — [`NoCacheStorage`](@ref),
239+
[`SingleCacheStorage`](@ref), or [`DictCacheStorage`](@ref), matching the intended cache
240+
mode.
241+
242+
# Arguments
243+
- `fw`: Tuple of `FunctionWrappers.FunctionWrapper`s, tried in order on call.
244+
- `cs`: Cache storage instance used by the fallback path.
245+
246+
# Type Parameters
247+
- `FW`: Tuple type of the wrapped `FunctionWrapper`s.
248+
- `P`: Fallback policy type, such as `Strict`, `AllowAll`, or `AllowNonIsBits`.
249+
- `CS`: Cache storage type, matching `typeof(cs)`.
250+
251+
# Returns
252+
- `FunctionWrappersWrapper{FW, P, CS}`: A callable wrapper around `fw`.
253+
254+
# Examples
255+
```jldoctest
256+
julia> using FunctionWrappers: FunctionWrapper
257+
258+
julia> fw = (FunctionWrapper{Float64, Tuple{Float64, Float64}}(+),);
259+
260+
julia> cs = FunctionWrappersWrappers.SingleCacheStorage();
261+
262+
julia> fww = FunctionWrappersWrapper{typeof(fw), AllowNonIsBits, typeof(cs)}(fw, cs);
263+
264+
julia> fww(1.0, 2.0)
265+
3.0
266+
```
267+
""" FunctionWrappersWrapper{FW, P, CS}(fw::FW, cs::CS) where {FW, P, CS}
268+
225269
"""
226270
FunctionWrappersWrapper{FW, P, CS}(f) -> FunctionWrappersWrapper{FW, P, CS}
227271

0 commit comments

Comments
 (0)