qubit_config/from/into_config_default.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10
11//! Default value adapters for typed configuration reads.
12
13use qubit_value::IntoValueDefault;
14
15/// Converts a caller-provided fallback value into the typed configuration result.
16pub trait IntoConfigDefault<T> {
17 /// Converts this fallback value into `T`.
18 fn into_config_default(self) -> T;
19}
20
21impl<T, D> IntoConfigDefault<T> for D
22where
23 D: IntoValueDefault<T>,
24{
25 #[inline]
26 fn into_config_default(self) -> T {
27 self.into_value_default()
28 }
29}