From f312c1806ed0726924bc5ac18f8d8b4e7af337dd Mon Sep 17 00:00:00 2001 From: Michael Macias Date: Mon, 23 Oct 2023 15:39:51 -0500 Subject: [PATCH] vcf/writer/builder: Add Builder::build_from_writer --- noodles-vcf/CHANGELOG.md | 2 ++ noodles-vcf/src/writer/builder.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/noodles-vcf/CHANGELOG.md b/noodles-vcf/CHANGELOG.md index ca6fabc49..489b9503f 100644 --- a/noodles-vcf/CHANGELOG.md +++ b/noodles-vcf/CHANGELOG.md @@ -13,6 +13,8 @@ Change instantiations of `vcf::reader::Builder` to `vcf::reader::Builder::default()`. + * vcf/writer/builder: Add `Builder::build_from_writer`. + ### Changed * vcf/reader/builder: Change `Builder::build_from_reader` to accept diff --git a/noodles-vcf/src/writer/builder.rs b/noodles-vcf/src/writer/builder.rs index 48c7f520a..084588a7b 100644 --- a/noodles-vcf/src/writer/builder.rs +++ b/noodles-vcf/src/writer/builder.rs @@ -37,4 +37,20 @@ impl Builder { Ok(Writer::new(writer)) } + + /// Builds a VCF writer from a writer. + /// + /// # Examples + /// + /// ``` + /// # use std::io; + /// use noodles_vcf as vcf; + /// let writer = vcf::writer::Builder.build_from_writer(io::sink()); + /// ``` + pub fn build_from_writer(self, writer: W) -> Writer + where + W: Write, + { + Writer::new(writer) + } }