Skip to content

Commit ae6cb29

Browse files
authored
fix: ExecutionOptions::default() now respects defaults used in ExecutionOptionsBuilder::default() (#499)
1 parent f77952b commit ae6cb29

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

crates/lib/src/qpu/api.rs

+27-4
Original file line numberDiff line numberDiff line change
@@ -327,26 +327,34 @@ pub type QpuConnectionOptions = ExecutionOptions;
327327
/// Builder for setting up [`QpuConnectionOptions`].
328328
pub type QpuConnectionOptionsBuilder = ExecutionOptionsBuilder;
329329

330-
/// Options avaialable when executing a job on a QPU.
330+
/// Options available when executing a job on a QPU.
331331
///
332332
/// Use [`Default`] to get a reasonable set of defaults, or start with [`ExecutionOptionsBuilder`]
333333
/// to build a custom set of options.
334-
#[derive(Builder, Clone, Debug, Default, PartialEq)]
334+
#[derive(Builder, Clone, Debug, PartialEq)]
335335
pub struct ExecutionOptions {
336336
#[doc = "The [`ConnectionStrategy`] to use to establish a connection to the QPU."]
337337
#[builder(default)]
338338
connection_strategy: ConnectionStrategy,
339339
#[doc = "The timeout to use for the request, defaults to 30 seconds. If set to `None`, then there is no timeout."]
340340
#[builder(default = "Some(Duration::from_secs(30))")]
341341
timeout: Option<Duration>,
342-
#[doc = "Options avaialable when executing a job on a QPU, particular to the execution service's API."]
342+
#[doc = "Options available when executing a job on a QPU, particular to the execution service's API."]
343343
#[builder(default = "None")]
344344
api_options: Option<InnerApiExecutionOptions>,
345345
}
346346

347+
impl Default for ExecutionOptions {
348+
fn default() -> Self {
349+
ExecutionOptionsBuilder::default().build().expect(
350+
"Should be able to derive a default set of the ExecutionOptions from the builder.",
351+
)
352+
}
353+
}
354+
347355
impl Eq for ExecutionOptions {}
348356

349-
/// Options avaialable when executing a job on a QPU, particular to the execution service's API.
357+
/// Options available when executing a job on a QPU, particular to the execution service's API.
350358
/// This is a conventent alias for [`InnerApiExecutionOptions`] which provides a builder.
351359
///
352360
/// Use [`Default`] to get a reasonable set of defaults, or start with [`ApiExecutionOptionsBuilder`]
@@ -702,3 +710,18 @@ pub enum QpuApiError {
702710
message: String,
703711
},
704712
}
713+
714+
#[cfg(test)]
715+
mod test {
716+
use crate::qpu::api::ExecutionOptions;
717+
718+
use super::ExecutionOptionsBuilder;
719+
720+
#[test]
721+
fn test_default_execution_options() {
722+
assert_eq!(
723+
ExecutionOptions::default(),
724+
ExecutionOptionsBuilder::default().build().unwrap(),
725+
);
726+
}
727+
}

0 commit comments

Comments
 (0)