dave on Nostr: fn common_char_functional<'a>(str1: &'a str, str2: &'a str) -> &'a str { let ...
fn common_char_functional<'a>(str1: &'a str, str2: &'a str) -> &'a str {
let common_chars = str1.chars().filter(|ch1| str2.contains(*ch1)).collect::<String>();
let result = Box::leak(common_chars.into_boxed_str());
result
}
Published at
2023-02-10 08:37:56Event JSON
{
"id": "40f25d44e56a08288f02525594e02f947c024c0ba707e4f183089a7b26122d42",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1676018276,
"kind": 1,
"tags": [
[
"e",
"cf6ec50761a809a533e32de590d94eacd78c544265a3f67e215836d468ad9df5",
"",
"root"
],
[
"e",
"4da17211e84a2ce031c587503bc4bef0624ae671593973473c47f641b8995e55",
"",
"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 common_chars = str1.chars().filter(|ch1| str2.contains(*ch1)).collect::\u003cString\u003e();\n let result = Box::leak(common_chars.into_boxed_str());\n result\n}",
"sig": "521c219c20a653a9e81d89e4970d0dd5ed65b01775301e9861dfb28a9be4330e564be45b0d4bc986f7575c4897578d8ec360abbbe83750535efa7b72bd91293b"
}