added ToHref impl for Rc<str> (#2857)

This commit is contained in:
Matt Kane 2024-08-18 15:52:42 -05:00 committed by GitHub
parent 78dc8b4410
commit ba40560ad7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@ use crate::{
};
use leptos::{children::Children, oco::Oco, prelude::*, *};
use reactive_graph::{computed::ArcMemo, owner::use_context};
use std::borrow::Cow;
use std::{borrow::Cow, rc::Rc};
/// Describes a value that is either a static or a reactive URL, i.e.,
/// a [`String`], a [`&str`], or a reactive `Fn() -> String`.
@ -41,6 +41,13 @@ impl ToHref for Oco<'_, str> {
}
}
impl ToHref for Rc<str> {
fn to_href(&self) -> Box<dyn Fn() -> String + '_> {
let s = self.to_string();
Box::new(move || s.clone())
}
}
impl<F> ToHref for F
where
F: Fn() -> String + 'static,