//! The app's ONE fractional-order step, and the midpoint that goes with it. //! The port of `packages/core/src/engine/position.ts`. //! //! It lived in the tag-curation engine until schema v16 retired the tags. The //! module went; this pair did not, because it is what orders the pinned news //! topics and every other list a person drags a row inside. //! //! Do not merge these with [`crate::rules::memory_order`]'s pair, which shares //! both names and NEITHER contract: memory's step is 1000 and its //! `position_between` answers `None` when the gap is exhausted so the caller //! renumbers. This one never refuses. /// The gap positions start from when an order is first materialised /// (`index * STEP`), leaving room for midpoint inserts between any two /// neighbours for a long time before a re-spread is ever needed. pub const POSITION_STEP: f64 = 1024.0; /// A position strictly between two neighbours (either side open). /// /// The caller passes the effective positions of the rows above/below the drop /// slot; a `None` side means the slot touches that end of the list. pub fn position_between(before: Option, after: Option) -> f64 { match (before, after) { (None, None) => POSITION_STEP, (None, Some(after)) => after - POSITION_STEP, (Some(before), None) => before + POSITION_STEP, (Some(before), Some(after)) => (before + after) / 2.0, } } #[cfg(test)] #[path = "position_tests.rs"] mod tests;