Skip to content

Cow<'_, str> doesn't implement FastWritable #431

@C0D3-M4513R

Description

@C0D3-M4513R
error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> app/src/rocket/content/admin/domain.rs:102:22
    |
102 |             content: Cow::Borrowed(VIEW_ADMIN_PANEL_DOMAIN_NO_PERM),
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `Sized` is not implemented for `str`, which is required by `Cow<'_, str>: FastWritable`
    = help: the trait `FastWritable` is implemented for `Cow<'_, T>`
    = note: required for `Cow<'_, str>` to implement `FastWritable`
note: required by a bound in `domain_base::DomainBase`
   --> app/src/rocket/template/authenticated/domain_base.rs:7:30
    |
7   | pub struct DomainBase<'a, T: FastWritable> {
    |                              ^^^^^^^^^^^^ required by this bound in `DomainBase`

DomainBase:

use std::borrow::Cow;
use askama::{FastWritable, Template};
use crate::rocket::auth::session::Permission;

#[derive(Template)]
#[template(path = "authenticated/domain_base.html")]
pub struct DomainBase<'a, T: FastWritable> {
    pub domain: &'a str,
    pub permission: Option<Permission>,
    pub content: T,
}

The typebound in

impl<T: FastWritable + alloc::borrow::ToOwned> FastWritable for alloc::borrow::Cow<'_, T> {
should probably include + ?Sized?

Edit: also, I just did realize, that I don't need to wrap the content in a Cow.
Nevertheless I feel like this should be addressed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions