subscript(as:)
Temporarily rebinds this output’s storage buffer to an encoder of the specified type. This function does not add any headers or trailers; to emit a complete BSON frame, mutate through subscript(as:in:)
.
subscript<Encoder>(as _: Encoder.Type) -> Encoder where Encoder : BSON.Encoder { mutating get set }
Some encoders may write on init(_:)
to preserve application-level invariants, so type rebinding can have mutating effects even if the coroutine performs no writes.