dave on Nostr: fn common_char_functional<'a>(str1: &'a str, str2: &'a str) -> &'a str { let result = ...
fn common_char_functional<'a>(str1: &'a str, str2: &'a str) -> &'a str {
let result = str1.chars()
.filter(|ch1| str2.contains(*ch1))
.collect::<String>();
Box::leak(result.into_boxed_str())
}
Published at
2023-02-10 08:42:14Event JSON
{
"id": "53c5a64174910777d9793132de793c853f67cff898b6eafa0311852d4bac4ca1",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1676018534,
"kind": 1,
"tags": [
[
"e",
"cf6ec50761a809a533e32de590d94eacd78c544265a3f67e215836d468ad9df5",
"",
"root"
],
[
"e",
"1f1fbd2a71ff708848b67ae86a95b32e9b04f1f81c61140e3885c784ab835da1",
"",
"reply"
],
[
"p",
"07df91ae471e765c996d5bd1f16be175c83eb2f6efdc5c9aa7503309dc7872ee"
],
[
"p",
"72c29c440a399fa8ecd16227d38aba96d57ac6e2b2bbde307c6fd2d8db6fe810"
]
],
"content": "fn common_char_functional\u003c'a\u003e(str1: \u0026'a str, str2: \u0026'a str) -\u003e \u0026'a str {\n let result = str1.chars()\n .filter(|ch1| str2.contains(*ch1))\n .collect::\u003cString\u003e();\n Box::leak(result.into_boxed_str())\n}",
"sig": "f4ac65c6d3d0438a405efc726d00bdb241b1e86d7eecce83a879e506ab74f832ef8c508c875329eb556fb43886f2e9b77cc53b2e5b354657fdc4388eec5ae503"
}