You would need to define
struct Cogg{F}
x::F
end
so that the type of cogg.x is known at compile-time. This will lead to in-lining in some cases, for example:
julia> cogg = Cogg(x->2x)
Cogg{var"#1#2"}(var"#1#2"())
julia> f(c) = c.x(2)
f (generic function with 1 method)
julia> @code_llvm(f(cogg))
; @ REPL[3]:1 within `f`
define i64 @julia_f_177() #0 {
top:
ret i64 4
}