Skip to content

Commit c24c510

Browse files
committed
Document why we use IntoIterator
1 parent 9c9c51a commit c24c510

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

crates/stackable-operator/src/role_utils.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,12 @@ impl<K: Resource> Display for RoleGroupRef<K> {
543543
/// This is the case when all `replicas` are set to [`Some<u16>`], in which case they are simply
544544
/// summed.
545545
///
546-
/// The argument `zero_replicas_counting` is a safety mechanism, which allows the caller to
547-
/// decide if an explicit replica count of `0` should be treated as [`None`]. It also means that
548-
/// [`None`] is returned in case no roleGroups are configured at all.
546+
/// The argument `zero_replicas_counting` is a safety mechanism, which allows the caller to decide
547+
/// if an explicit replica count of `0` should be treated as [`None`]. It also means that [`None`]
548+
/// is returned in case no roleGroups are configured at all.
549+
//
550+
// Note: We are using a [`IntoIterator`] combined with `.peekable()` over [`ExactSizeIterator`] to
551+
// have minimal bound requirements on the caller.
549552
pub fn fixed_replica_count<I: IntoIterator<Item = Option<u16>>>(
550553
replicas: I,
551554
zero_replicas_counting: ZeroReplicasCounting,
@@ -569,9 +572,12 @@ pub fn fixed_replica_count<I: IntoIterator<Item = Option<u16>>>(
569572

570573
/// Returns the estimated total number of replicas across all role groups.
571574
///
572-
/// Unlike [`Self::fixed_replica_count`], this always returns a value: a role group with an unset
573-
/// (i.e. [`None`]) replica count is assumed to run a single replica. Use this when a best-effort
574-
/// estimate is needed even though the exact number of replicas is not hard-coded.
575+
/// Unlike [`fixed_replica_count`], this always returns a value: a role group with an unset (i.e.
576+
/// [`None`]) replica count is assumed to run a single replica. Use this when a best-effort estimate
577+
/// is needed even though the exact number of replicas is not hard-coded.
578+
//
579+
// Note: We are using a [`IntoIterator`] combined with `.peekable()` over [`ExactSizeIterator`] to
580+
// have minimal bound requirements on the caller.
575581
pub fn estimated_replica_count<I: IntoIterator<Item = Option<u16>>>(replicas: I) -> u32 {
576582
replicas
577583
.into_iter()

0 commit comments

Comments
 (0)