Skip to content

Commit 38f8df0

Browse files
committed
docs(kvs): correct MvccSource Arc<dyn> over-claim (CodeRabbit)
`MvccSource::next_version` uses return-position `impl Trait` (RPITIT), which makes the trait non-object-safe, so the `Arc<dyn MvccSource>` the doc comment claimed will not compile. The trait is `#[allow(dead_code)]` (no consumer yet); rather than box the future (a per-call heap allocation for an unused trait-object capability), correct the doc to state zero-cost static dispatch and that a boxed-future variant can be added if runtime-pluggable sources are ever needed. Doc-only change. https://claude.ai/code/session_01R9AWgFa65uPnLyS2my2d2R
1 parent 5997eea commit 38f8df0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

surrealdb/core/src/kvs/mvcc_source.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ use std::sync::atomic::{AtomicU64, Ordering};
5353
/// previously returned by the same instance.
5454
/// - Values need not be consecutive; gaps are permitted (for example, an
5555
/// HLC-backed source will return wall-clock milliseconds which can jump).
56-
/// - Implementations must be `Send + Sync` so they can be stored inside
57-
/// `Arc<dyn MvccSource>` and shared across Tokio tasks.
56+
/// - Implementations must be `Send + Sync` so a concrete source can be
57+
/// shared across Tokio tasks (e.g. `Arc<LocalGeneratedMvcc>`). Note the
58+
/// trait itself is NOT object-safe: `next_version` uses return-position
59+
/// `impl Trait` (RPITIT) for zero-cost static dispatch, so `dyn MvccSource`
60+
/// / `Arc<dyn MvccSource>` will not compile. A future consumer that needs
61+
/// runtime-pluggable sources can add a boxed-future variant at that point.
5862
///
5963
/// [`next_version`]: MvccSource::next_version
6064
pub trait MvccSource: Send + Sync {

0 commit comments

Comments
 (0)