File tree Expand file tree Collapse file tree 6 files changed +9
-29
lines changed
Expand file tree Collapse file tree 6 files changed +9
-29
lines changed Original file line number Diff line number Diff line change 5454 if : github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
5555 strategy :
5656 matrix :
57- rust : [stable, nightly, "1.85 "] # 1.85 is the MSRV
57+ rust : [stable, nightly, "1.86 "] # 1.85 is the MSRV
5858 os : [ubuntu-latest, macos-latest, windows-latest]
5959
6060 name : Build & test
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ resolver = "2"
1919
2020[workspace .package ]
2121edition = " 2024"
22- rust-version = " 1.85 "
22+ rust-version = " 1.86 "
2323license = " MIT OR Apache-2.0"
2424homepage = " https://cot.rs"
2525repository = " https://github.com/cot-rs/cot"
Original file line number Diff line number Diff line change @@ -97,10 +97,6 @@ impl AdminModelDeriveBuilder {
9797 quote ! {
9898 #[ #crate_ident:: __private:: async_trait]
9999 impl #crate_ident:: admin:: AdminModel for #name {
100- fn as_any( & self ) -> & dyn :: core:: any:: Any {
101- self
102- }
103-
104100 async fn get_total_object_counts(
105101 request: & #crate_ident:: request:: Request ,
106102 ) -> #crate_ident:: Result <u64 > {
Original file line number Diff line number Diff line change @@ -528,10 +528,8 @@ impl<T: AdminModel + Send + Sync + 'static> AdminModelManager for DefaultAdminMo
528528 }
529529
530530 async fn form_context_from_object ( & self , object : Box < dyn AdminModel > ) -> Box < dyn FormContext > {
531- let object_casted = object
532- . as_any ( )
533- . downcast_ref :: < T > ( )
534- . expect ( "Invalid object type" ) ;
531+ let object_any: & dyn Any = & * object;
532+ let object_casted = object_any. downcast_ref :: < T > ( ) . expect ( "Invalid object type" ) ;
535533
536534 T :: form_context_from_self ( object_casted) . await
537535 }
@@ -557,11 +555,6 @@ impl<T: AdminModel + Send + Sync + 'static> AdminModelManager for DefaultAdminMo
557555 note = "add #[derive(cot::admin::AdminModel)] to the struct to automatically derive the trait"
558556) ]
559557pub trait AdminModel : Any + Send + ' static {
560- /// Returns the object as an `Any` trait object.
561- // TODO: consider removing this when Rust trait_upcasting is stabilized and we
562- // bump the MSRV (lands in Rust 1.86)
563- fn as_any ( & self ) -> & dyn Any ;
564-
565558 /// Get the objects of this model.
566559 async fn get_objects ( request : & Request , pagination : Pagination ) -> cot:: Result < Vec < Self > >
567560 where
Original file line number Diff line number Diff line change @@ -447,11 +447,7 @@ where
447447 Inner ( handler, PhantomData , PhantomData )
448448}
449449
450- pub ( crate ) trait BoxApiEndpointRequestHandler : BoxRequestHandler + AsApiRoute {
451- // TODO: consider removing this when Rust trait_upcasting is stabilized and we
452- // bump the MSRV (lands in Rust 1.86)
453- fn as_box_request_handler ( & self ) -> & ( dyn BoxRequestHandler + Send + Sync ) ;
454- }
450+ pub ( crate ) trait BoxApiEndpointRequestHandler : BoxRequestHandler + AsApiRoute { }
455451
456452pub ( crate ) fn into_box_api_endpoint_request_handler < HandlerParams , H > (
457453 handler : H ,
@@ -486,13 +482,9 @@ where
486482 }
487483 }
488484
489- impl < HandlerParams , H > BoxApiEndpointRequestHandler for Inner < HandlerParams , H >
490- where
491- H : RequestHandler < HandlerParams > + AsApiRoute + Send + Sync ,
485+ impl < HandlerParams , H > BoxApiEndpointRequestHandler for Inner < HandlerParams , H > where
486+ H : RequestHandler < HandlerParams > + AsApiRoute + Send + Sync
492487 {
493- fn as_box_request_handler ( & self ) -> & ( dyn BoxRequestHandler + Send + Sync ) {
494- self
495- }
496488 }
497489
498490 Inner ( handler, PhantomData )
Original file line number Diff line number Diff line change @@ -172,10 +172,9 @@ impl Router {
172172 #[ cfg( feature = "openapi" ) ]
173173 RouteInner :: ApiHandler ( handler) => {
174174 if matches_fully {
175+ let handler: & ( dyn BoxRequestHandler + Send + Sync ) = & * * handler;
175176 return Some ( HandlerFound {
176- // TODO: consider removing this when Rust trait_upcasting is
177- // stabilized and we bump the MSRV (lands in Rust 1.86)
178- handler : handler. as_box_request_handler ( ) ,
177+ handler,
179178 app_name : self . app_name . clone ( ) ,
180179 name : route. name . clone ( ) ,
181180 params : Self :: matches_to_path_params ( & matches, Vec :: new ( ) ) ,
You can’t perform that action at this time.
0 commit comments