Ipmlement conversions from Account to (Arc|Box|Rc)<Acc>

korrat
Aug 6, 2024, 8:41 AM
BKGLIMJK7PSYX523YFN2W6KRLTJLJNWPGLQBN3COWWNIB6CWADOAC

Dependencies

  • [2] NG5QXPZH Extract Account into separate crate
  • [*] YDK6X6PP add a library of important types for beancount
  • [*] 2JBFREZG enable additional warnings

Change contents

  • edit in beancount/types/src/core/account.rs at line 8
    [2.1750]
    [5.13676]
    use alloc::rc::Rc;
    use alloc::sync::Arc;
  • edit in beancount/types/src/core/account.rs at line 156
    [4.12723]
    [4.12723]
    impl From<&Acc> for Arc<Acc> {
    fn from(value: &Acc) -> Self {
    let raw = Arc::<str>::from(&value.name);
    unsafe { Self::from_raw(Arc::into_raw(raw) as _) }
    }
    }
    impl From<Account> for Arc<Acc> {
    fn from(value: Account) -> Self {
    let raw = Arc::<str>::from(value.name);
    unsafe { Self::from_raw(Arc::into_raw(raw) as _) }
    }
    }
    impl From<&Acc> for Box<Acc> {
    fn from(value: &Acc) -> Self {
    let raw = Box::<str>::from(&value.name);
    unsafe { Self::from_raw(Box::into_raw(raw) as _) }
    }
    }
  • edit in beancount/types/src/core/account.rs at line 178
    [4.12724]
    [4.12724]
    impl From<Account> for Box<Acc> {
    fn from(value: Account) -> Self {
    let raw = value.name.into_boxed_str();
    unsafe { Self::from_raw(Box::into_raw(raw) as _) }
    }
    }
    impl From<&Acc> for Rc<Acc> {
    fn from(value: &Acc) -> Self {
    let raw = Rc::<str>::from(&value.name);
    unsafe { Self::from_raw(Rc::into_raw(raw) as _) }
    }
    }
    impl From<Account> for Rc<Acc> {
    fn from(value: Account) -> Self {
    let raw = Rc::<str>::from(value.name);
    unsafe { Self::from_raw(Rc::into_raw(raw) as _) }
    }
    }