Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
rust: [stable, nightly, "1.85"] # 1.85 is the MSRV
rust: [stable, nightly, "1.86"] # 1.85 is the MSRV
os: [ubuntu-latest, macos-latest, windows-latest]

name: Build & test
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resolver = "2"

[workspace.package]
edition = "2024"
rust-version = "1.85"
rust-version = "1.86"
license = "MIT OR Apache-2.0"
homepage = "https://cot.rs"
repository = "https://github.com/cot-rs/cot"
Expand Down
4 changes: 0 additions & 4 deletions cot-macros/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ impl AdminModelDeriveBuilder {
quote! {
#[#crate_ident::__private::async_trait]
impl #crate_ident::admin::AdminModel for #name {
fn as_any(&self) -> &dyn ::core::any::Any {
self
}

async fn get_total_object_counts(
request: &#crate_ident::request::Request,
) -> #crate_ident::Result<u64> {
Expand Down
11 changes: 2 additions & 9 deletions cot/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,8 @@ impl<T: AdminModel + Send + Sync + 'static> AdminModelManager for DefaultAdminMo
}

async fn form_context_from_object(&self, object: Box<dyn AdminModel>) -> Box<dyn FormContext> {
let object_casted = object
.as_any()
.downcast_ref::<T>()
.expect("Invalid object type");
let object_any: &dyn Any = &*object;
let object_casted = object_any.downcast_ref::<T>().expect("Invalid object type");

T::form_context_from_self(object_casted).await
}
Expand All @@ -557,11 +555,6 @@ impl<T: AdminModel + Send + Sync + 'static> AdminModelManager for DefaultAdminMo
note = "add #[derive(cot::admin::AdminModel)] to the struct to automatically derive the trait"
)]
pub trait AdminModel: Any + Send + 'static {
/// Returns the object as an `Any` trait object.
// TODO: consider removing this when Rust trait_upcasting is stabilized and we
// bump the MSRV (lands in Rust 1.86)
fn as_any(&self) -> &dyn Any;

/// Get the objects of this model.
async fn get_objects(request: &Request, pagination: Pagination) -> cot::Result<Vec<Self>>
where
Expand Down
14 changes: 3 additions & 11 deletions cot/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,7 @@ where
Inner(handler, PhantomData, PhantomData)
}

pub(crate) trait BoxApiEndpointRequestHandler: BoxRequestHandler + AsApiRoute {
// TODO: consider removing this when Rust trait_upcasting is stabilized and we
// bump the MSRV (lands in Rust 1.86)
fn as_box_request_handler(&self) -> &(dyn BoxRequestHandler + Send + Sync);
}
pub(crate) trait BoxApiEndpointRequestHandler: BoxRequestHandler + AsApiRoute {}

pub(crate) fn into_box_api_endpoint_request_handler<HandlerParams, H>(
handler: H,
Expand Down Expand Up @@ -486,13 +482,9 @@ where
}
}

impl<HandlerParams, H> BoxApiEndpointRequestHandler for Inner<HandlerParams, H>
where
H: RequestHandler<HandlerParams> + AsApiRoute + Send + Sync,
impl<HandlerParams, H> BoxApiEndpointRequestHandler for Inner<HandlerParams, H> where
H: RequestHandler<HandlerParams> + AsApiRoute + Send + Sync
{
fn as_box_request_handler(&self) -> &(dyn BoxRequestHandler + Send + Sync) {
self
}
}

Inner(handler, PhantomData)
Expand Down
5 changes: 2 additions & 3 deletions cot/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ impl Router {
#[cfg(feature = "openapi")]
RouteInner::ApiHandler(handler) => {
if matches_fully {
let handler: &(dyn BoxRequestHandler + Send + Sync) = &**handler;
return Some(HandlerFound {
// TODO: consider removing this when Rust trait_upcasting is
// stabilized and we bump the MSRV (lands in Rust 1.86)
handler: handler.as_box_request_handler(),
handler,
app_name: self.app_name.clone(),
name: route.name.clone(),
params: Self::matches_to_path_params(&matches, Vec::new()),
Expand Down
Loading