ア゛ーーーー AsRef が lifetime 付きの &'a str を返せない問題!!!
Conversation
Notices
-
Embed this notice
らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Thursday, 07-Dec-2023 23:24:14 JST らりお・ザ・何らかの🈗然㊌ソムリエ
-
Embed this notice
らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Thursday, 07-Dec-2023 23:24:25 JST らりお・ザ・何らかの🈗然㊌ソムリエ
Into<&'a str> とかで……いや厳しいか……
-
Embed this notice
らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Thursday, 07-Dec-2023 23:24:25 JST らりお・ザ・何らかの🈗然㊌ソムリエ
pub struct Foo<S>(S);
impl<S: AsRef<S>> Foo<S> {
fn as_str(&self) -> &str { s.as_ref() }
}なんだけど、これ Foo<&'a str> からでも &'b str (where Foo: 'b, 'a: 'b) しか返せなくて、そこは &'a str を返してあげたいよねというのが問題の本質
-
Embed this notice
ドッグ (linda_pp@mstdn.jp)'s status on Thursday, 07-Dec-2023 23:24:32 JST ドッグ
@lo48576 コンテキスト分かってないですが AsRef<str> + 'a とかでしょうか?
-
Embed this notice