diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-11 16:33:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-11 16:33:05 +0900 |
| commit | 27d00055df8691a6bd99aaf38633a7338b16cc6a (patch) | |
| tree | 4af17ccff5f8c2d09156fa62c559e60e3e683dac /crates/shirabe/src/repository | |
| parent | 1ec2220def43e37e5a65b96dde93c19b493258f4 (diff) | |
| download | php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.tar.gz php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.tar.zst php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.zip | |
chore: use fully-qualified name for Rc/RefCell
Diffstat (limited to 'crates/shirabe/src/repository')
| -rw-r--r-- | crates/shirabe/src/repository/array_repository.rs | 13 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/handle.rs | 75 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/vcs_driver_interface.rs | 6 |
3 files changed, 48 insertions, 46 deletions
diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs index dc31baad..6f5e4194 100644 --- a/crates/shirabe/src/repository/array_repository.rs +++ b/crates/shirabe/src/repository/array_repository.rs @@ -16,20 +16,19 @@ use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{implode, preg_quote, strtolower}; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; use std::rc::Weak; /// A repository implementation that simply stores packages in an array #[derive(Debug)] pub struct ArrayRepository { - pub(crate) packages: RefCell<Option<Vec<BasePackageHandle>>>, + pub(crate) packages: std::cell::RefCell<Option<Vec<BasePackageHandle>>>, /// @var ?array<BasePackage> indexed by package unique name and used to cache hasPackage calls - pub(crate) package_map: RefCell<Option<IndexMap<String, BasePackageHandle>>>, + pub(crate) package_map: std::cell::RefCell<Option<IndexMap<String, BasePackageHandle>>>, /// Weak reference to the outermost repository handle wrapping this `ArrayRepository`, /// injected via `set_self_handle`. Used to wire package -> repository back-references. - self_weak: RefCell<Option<RepositoryInterfaceWeakHandle>>, + self_weak: std::cell::RefCell<Option<RepositoryInterfaceWeakHandle>>, } impl ArrayRepository { @@ -120,9 +119,9 @@ impl ArrayRepository { /// @param array<PackageInterface> $packages pub fn new(packages: Vec<PackageInterfaceHandle>) -> anyhow::Result<Self> { let this = Self { - packages: RefCell::new(None), - package_map: RefCell::new(None), - self_weak: RefCell::new(None), + packages: std::cell::RefCell::new(None), + package_map: std::cell::RefCell::new(None), + self_weak: std::cell::RefCell::new(None), }; for package in packages { this.add_package(package)?; diff --git a/crates/shirabe/src/repository/handle.rs b/crates/shirabe/src/repository/handle.rs index 64cb5b73..f093f66b 100644 --- a/crates/shirabe/src/repository/handle.rs +++ b/crates/shirabe/src/repository/handle.rs @@ -8,35 +8,36 @@ use crate::repository::{ }; use indexmap::IndexMap; use shirabe_semver::constraint::AnyConstraint; -use std::cell::{Ref, RefCell, RefMut}; -use std::rc::{Rc, Weak}; +use std::cell::{Ref, RefMut}; +use std::rc::Weak; /// Shared reference to a repository. Corresponds to PHP `RepositoryInterface`. #[derive(Debug, Clone)] -pub struct RepositoryInterfaceHandle(Rc<RefCell<dyn RepositoryInterface>>); +pub struct RepositoryInterfaceHandle(std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>>); /// Weak back-reference held by packages to the repository that owns them. -pub type RepositoryInterfaceWeakHandle = Weak<RefCell<dyn RepositoryInterface>>; +pub type RepositoryInterfaceWeakHandle = Weak<std::cell::RefCell<dyn RepositoryInterface>>; impl RepositoryInterfaceHandle { /// Wraps a concrete repository in a shared handle and injects its own weak reference so that /// `add_package` can wire package -> repository back-references (PHP `setRepository($this)`). pub fn new<T: RepositoryInterface + 'static>(repository: T) -> Self { - let rc: Rc<RefCell<dyn RepositoryInterface>> = Rc::new(RefCell::new(repository)); - rc.borrow().set_self_handle(Rc::downgrade(&rc)); + let rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(repository)); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc)); Self(rc) } - pub fn from_rc(rc: Rc<RefCell<dyn RepositoryInterface>>) -> Self { + pub fn from_rc(rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>>) -> Self { Self(rc) } - pub fn as_rc(&self) -> &Rc<RefCell<dyn RepositoryInterface>> { + pub fn as_rc(&self) -> &std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> { &self.0 } pub fn downgrade(&self) -> RepositoryInterfaceWeakHandle { - Rc::downgrade(&self.0) + std::rc::Rc::downgrade(&self.0) } pub fn borrow(&self) -> Ref<'_, dyn RepositoryInterface> { @@ -49,12 +50,12 @@ impl RepositoryInterfaceHandle { /// PHP `===` (reference identity). pub fn ptr_eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } /// Stable identity usable as a map key (PHP `spl_object_hash`). pub fn ptr_id(&self) -> usize { - Rc::as_ptr(&self.0) as *const () as usize + std::rc::Rc::as_ptr(&self.0) as *const () as usize } /// PHP `instanceof T` for a concrete repository type. Keeps the `RefCell` borrow internal. @@ -63,13 +64,15 @@ impl RepositoryInterfaceHandle { } /// Downcasts the shared handle to a concrete repository type, preserving shared ownership. - pub fn downcast_rc<T: RepositoryInterface + 'static>(&self) -> Option<Rc<RefCell<T>>> { + pub fn downcast_rc<T: RepositoryInterface + 'static>( + &self, + ) -> Option<std::rc::Rc<std::cell::RefCell<T>>> { if self.0.borrow().as_any().is::<T>() { let rc = self.0.clone(); - let ptr = Rc::into_raw(rc) as *const RefCell<T>; + let ptr = std::rc::Rc::into_raw(rc) as *const std::cell::RefCell<T>; // SAFETY: is::<T>() proved the value is `T`, and handles are always allocated as // `Rc::new(RefCell::new(concrete))`, so the layout matches `RcBox<RefCell<T>>`. - Some(unsafe { Rc::from_raw(ptr) }) + Some(unsafe { std::rc::Rc::from_raw(ptr) }) } else { None } @@ -191,7 +194,7 @@ impl RepositoryInterfaceHandle { impl PartialEq for RepositoryInterfaceHandle { fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } } @@ -205,21 +208,22 @@ impl std::hash::Hash for RepositoryInterfaceHandle { /// Typed shared handle over `LockArrayRepository`. #[derive(Debug, Clone)] -pub struct LockArrayRepositoryHandle(Rc<RefCell<LockArrayRepository>>); +pub struct LockArrayRepositoryHandle(std::rc::Rc<std::cell::RefCell<LockArrayRepository>>); impl LockArrayRepositoryHandle { pub fn new(repository: LockArrayRepository) -> Self { - let rc: Rc<RefCell<LockArrayRepository>> = Rc::new(RefCell::new(repository)); - let rc_dyn: Rc<RefCell<dyn RepositoryInterface>> = rc.clone(); - rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + let rc: std::rc::Rc<std::cell::RefCell<LockArrayRepository>> = + std::rc::Rc::new(std::cell::RefCell::new(repository)); + let rc_dyn: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = rc.clone(); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc_dyn)); Self(rc) } - pub fn from_rc(rc: Rc<RefCell<LockArrayRepository>>) -> Self { + pub fn from_rc(rc: std::rc::Rc<std::cell::RefCell<LockArrayRepository>>) -> Self { Self(rc) } - pub fn as_rc(&self) -> &Rc<RefCell<LockArrayRepository>> { + pub fn as_rc(&self) -> &std::rc::Rc<std::cell::RefCell<LockArrayRepository>> { &self.0 } @@ -236,24 +240,24 @@ impl LockArrayRepositoryHandle { } pub fn ptr_eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } pub fn ptr_id(&self) -> usize { - Rc::as_ptr(&self.0) as *const () as usize + std::rc::Rc::as_ptr(&self.0) as *const () as usize } } impl From<LockArrayRepositoryHandle> for RepositoryInterfaceHandle { fn from(h: LockArrayRepositoryHandle) -> Self { - let rc: Rc<RefCell<dyn RepositoryInterface>> = h.0; + let rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = h.0; RepositoryInterfaceHandle::from_rc(rc) } } impl PartialEq for LockArrayRepositoryHandle { fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } } @@ -267,21 +271,22 @@ impl std::hash::Hash for LockArrayRepositoryHandle { /// Typed shared handle over `PlatformRepository`. #[derive(Debug, Clone)] -pub struct PlatformRepositoryHandle(Rc<RefCell<PlatformRepository>>); +pub struct PlatformRepositoryHandle(std::rc::Rc<std::cell::RefCell<PlatformRepository>>); impl PlatformRepositoryHandle { pub fn new(repository: PlatformRepository) -> Self { - let rc: Rc<RefCell<PlatformRepository>> = Rc::new(RefCell::new(repository)); - let rc_dyn: Rc<RefCell<dyn RepositoryInterface>> = rc.clone(); - rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + let rc: std::rc::Rc<std::cell::RefCell<PlatformRepository>> = + std::rc::Rc::new(std::cell::RefCell::new(repository)); + let rc_dyn: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = rc.clone(); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc_dyn)); Self(rc) } - pub fn from_rc(rc: Rc<RefCell<PlatformRepository>>) -> Self { + pub fn from_rc(rc: std::rc::Rc<std::cell::RefCell<PlatformRepository>>) -> Self { Self(rc) } - pub fn as_rc(&self) -> &Rc<RefCell<PlatformRepository>> { + pub fn as_rc(&self) -> &std::rc::Rc<std::cell::RefCell<PlatformRepository>> { &self.0 } @@ -294,24 +299,24 @@ impl PlatformRepositoryHandle { } pub fn ptr_eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } pub fn ptr_id(&self) -> usize { - Rc::as_ptr(&self.0) as *const () as usize + std::rc::Rc::as_ptr(&self.0) as *const () as usize } } impl From<PlatformRepositoryHandle> for RepositoryInterfaceHandle { fn from(h: PlatformRepositoryHandle) -> Self { - let rc: Rc<RefCell<dyn RepositoryInterface>> = h.0; + let rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = h.0; RepositoryInterfaceHandle::from_rc(rc) } } impl PartialEq for PlatformRepositoryHandle { fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } } diff --git a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs index fb10d0f2..628f78b7 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs @@ -5,8 +5,6 @@ use crate::io::IOInterface; use chrono::{DateTime, FixedOffset}; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; pub trait VcsDriverInterface: std::fmt::Debug { fn initialize(&mut self) -> anyhow::Result<()>; @@ -40,8 +38,8 @@ pub trait VcsDriverInterface: std::fmt::Debug { fn cleanup(&mut self) -> anyhow::Result<()>; fn supports( - io: Rc<RefCell<dyn IOInterface>>, - config: Rc<RefCell<Config>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, url: &str, deep: bool, ) -> anyhow::Result<bool> |
