From eea4efe87e455742ec17881ee93d8095925e8516 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 28 May 2026 22:43:11 +0900 Subject: refactor(repository): introduce Rc> handles for repositories Co-Authored-By: Claude Opus 4.7 (1M context) --- .../shirabe/src/repository/installed_repository.rs | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'crates/shirabe/src/repository/installed_repository.rs') diff --git a/crates/shirabe/src/repository/installed_repository.rs b/crates/shirabe/src/repository/installed_repository.rs index 486d4bd..b857bc2 100644 --- a/crates/shirabe/src/repository/installed_repository.rs +++ b/crates/shirabe/src/repository/installed_repository.rs @@ -16,7 +16,8 @@ use crate::repository::LockArrayRepository; use crate::repository::PlatformRepository; use crate::repository::RootPackageRepository; use crate::repository::{ - FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, SearchResult, + FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, + RepositoryInterfaceHandle, SearchResult, }; pub enum NeedleInput { @@ -36,7 +37,7 @@ pub struct InstalledRepository { } impl InstalledRepository { - pub fn new(repositories: Vec>) -> Self { + pub fn new(repositories: Vec) -> Self { let mut this = Self { inner: CompositeRepository::new(vec![]), }; @@ -381,25 +382,21 @@ impl InstalledRepository { results } - pub fn add_repository( - &mut self, - repository: Box, - ) -> anyhow::Result<()> { - // TODO(phase-b): cannot Any::is::; replace with a - // dedicated downcast/marker method on RepositoryInterface. - if repository.as_any().is::() - || repository.as_any().is::() - || repository.as_any().is::() + pub fn add_repository(&mut self, repository: RepositoryInterfaceHandle) -> anyhow::Result<()> { + if repository.is::() + || repository.is::() + || repository.is::() { self.inner.add_repository(repository); return Ok(()); } + let type_name = std::any::type_name_of_val(&*repository.borrow()).to_string(); + let repo_name = repository.get_repo_name(); Err(anyhow::anyhow!(LogicException { message: format!( "An InstalledRepository can not contain a repository of type {} ({})", - std::any::type_name_of_val(&*repository), - repository.get_repo_name(), + type_name, repo_name, ), code: 0, })) -- cgit v1.3.1