limbo/core/mvcc
Preston Thorpe 2e794934dd
Merge 'Use u64::from instead of .into()' from Elina
## Description
In certain edge cases, Into::into type inference fails and causes
library to fail to build in downstream crates
## Motivation and context
See https://github.com/ranile/turso-compile-fail
In this case, patching chrono to work with `ic-cdk` fails compilation of
turso. `ic-cdk` adds a dependency on `candid`, which provides some trait
implementations that make Into::into type inference break.
<details><summary>Error message</summary>
```
error[E0283]: type annotations needed
   --> /Users/me/.cargo/git/checkouts/turso-455557cd4a2364c7/2d78b53/core/mvcc/database/checkpoint_state_machine.rs:216:71
    |
216 |                         .is_some_and(|txid_max_old| b <= txid_max_old.into())
    |                                                       --              ^^^^
    |                                                       |
    |                                                       type must be known at this point
    |
    = note: multiple `impl`s satisfying `u64: PartialOrd<_>` found in the following crates: `candid`, `core`:
            - impl PartialOrd for u64;
            - impl PartialOrd<candid::types::number::Int> for u64;
            - impl PartialOrd<candid::types::number::Nat> for u64;
help: try using a fully qualified path to specify the expected types
    |
216 -                         .is_some_and(|txid_max_old| b <= txid_max_old.into())
216 +                         .is_some_and(|txid_max_old| b <= <std::num::NonZero<u64> as Into<T>>::into(txid_max_old))
    |

error[E0283]: type annotations needed
   --> /Users/me/.cargo/git/checkouts/turso-455557cd4a2364c7/2d78b53/core/mvcc/database/checkpoint_state_machine.rs:226:67
    |
226 |                     .is_some_and(|txid_max_old| e <= txid_max_old.into())
    |                                                   --              ^^^^
    |                                                   |
    |                                                   type must be known at this point
    |
    = note: multiple `impl`s satisfying `u64: PartialOrd<_>` found in the following crates: `candid`, `core`:
            - impl PartialOrd for u64;
            - impl PartialOrd<candid::types::number::Int> for u64;
            - impl PartialOrd<candid::types::number::Nat> for u64;
help: try using a fully qualified path to specify the expected types
    |
226 -                     .is_some_and(|txid_max_old| e <= txid_max_old.into())
226 +                     .is_some_and(|txid_max_old| e <= <std::num::NonZero<u64> as Into<T>>::into(txid_max_old))
    |

error[E0283]: type annotations needed
   --> /Users/me/.cargo/git/checkouts/turso-455557cd4a2364c7/2d78b53/core/mvcc/database/checkpoint_state_machine.rs:242:90
    |
242 |                     .is_none_or(|txid_max_old| begin_ts.is_some_and(|b| b > txid_max_old.into()));
    |                                                                           -              ^^^^
    |                                                                           |
    |                                                                           type must be known at this point
    |
    = note: multiple `impl`s satisfying `u64: PartialOrd<_>` found in the following crates: `candid`, `core`:
            - impl PartialOrd for u64;
            - impl PartialOrd<candid::types::number::Int> for u64;
            - impl PartialOrd<candid::types::number::Nat> for u64;
help: try using a fully qualified path to specify the expected types
    |
242 -                     .is_none_or(|txid_max_old| begin_ts.is_some_and(|b| b > txid_max_old.into()));
242 +                     .is_none_or(|txid_max_old| begin_ts.is_some_and(|b| b > <std::num::NonZero<u64> as Into<T>>::into(txid_max_old)));
    |

For more information about this error, try `rustc --explain E0283`.
error: could not compile `turso_core` (lib) due to 3 previous errors
```
</details>
## Description of AI Usage
All code is hand-written

Reviewed-by: Nikita Sivukhin (@sivukhin)

Closes #4293
2025-12-19 14:46:33 -05:00
..
database Merge 'Use u64::from instead of .into()' from Elina 2025-12-19 14:46:33 -05:00
persistent_storage Merge 'Mvcc bugfixes' from Jussi Saurio 2025-12-03 12:55:58 +02:00
clock.rs core/mvcc: Move source code to module 2025-02-05 13:25:16 +02:00
cursor.rs core/mvcc: Fix typos and use turso_assert 2025-12-19 12:52:01 +01:00
mod.rs use ArcSwap to store MvStore 2025-12-03 10:09:04 -03:00