From f9a80de86b16b15a4ee443d857ab13f398be1dda Mon Sep 17 00:00:00 2001 From: Kyle J Strand Date: Thu, 17 Oct 2024 14:53:09 -0600 Subject: [PATCH] feat: simple wrapper type to impl 'Quil' for an unparsed string-like type --- Cargo.lock | 6 +++--- quil-rs/src/quil.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b98d7afe..91a3cc7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1148,7 +1148,7 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quil-cli" -version = "0.6.1" +version = "0.6.2-rc.0" dependencies = [ "anyhow", "clap", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "quil-py" -version = "0.13.1" +version = "0.13.2-rc.0" dependencies = [ "indexmap", "ndarray", @@ -1172,7 +1172,7 @@ dependencies = [ [[package]] name = "quil-rs" -version = "0.29.1" +version = "0.29.2-rc.0" dependencies = [ "approx", "clap", diff --git a/quil-rs/src/quil.rs b/quil-rs/src/quil.rs index 27f9153b..c1703cbc 100644 --- a/quil-rs/src/quil.rs +++ b/quil-rs/src/quil.rs @@ -29,6 +29,21 @@ pub trait Quil: std::fmt::Debug { ) -> Result<(), ToQuilError>; } +// A simple wrapper type to represent Quil programs that are assumed to be valid +// without parsing them. +#[derive(Debug)] +pub struct RawQuil+std::fmt::Debug>(pub S); + +impl+std::fmt::Debug> Quil for RawQuil { + fn write( + &self, + writer: &mut impl std::fmt::Write, + _fall_back_to_debug: bool, + ) -> Result<(), ToQuilError> { + Ok(write!(writer, "{}", self.0.as_ref())?) + } +} + /// Per the Quil specification, an indentation is exactly 4 spaces. /// See [Quil 3-2](https://quil-lang.github.io/#3-2Syntactic-Rudiments) pub(crate) const INDENT: &str = " ";