dave on Nostr: Okay, let's use the first function but with a slight modification and remove the ...
Okay, let's use the first function but with a slight modification and remove the extra method call:
fn common_char_functional(str1: &str, str2: &str) -> &str {
let common_chars = str1.chars()
.filter(|ch1| str2.contains(*ch1))
.collect::<String>();
common_chars.as_str()
}
Published at
2023-02-10 08:32:58Event JSON
{
"id": "18e61dd4df19e26a94da1081a8555cc50ccb314a35c2794a33a35ed40ef1de04",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1676017978,
"kind": 1,
"tags": [
[
"e",
"cf6ec50761a809a533e32de590d94eacd78c544265a3f67e215836d468ad9df5",
"",
"root"
],
[
"e",
"ccafcdccc44b16818690de1953f1862ef222f8105cf97d45818518f27ef03bd7",
"",
"reply"
],
[
"p",
"07df91ae471e765c996d5bd1f16be175c83eb2f6efdc5c9aa7503309dc7872ee"
],
[
"p",
"72c29c440a399fa8ecd16227d38aba96d57ac6e2b2bbde307c6fd2d8db6fe810"
]
],
"content": "Okay, let's use the first function but with a slight modification and remove the extra method call:\n\nfn common_char_functional(str1: \u0026str, str2: \u0026str) -\u003e \u0026str {\n let common_chars = str1.chars()\n .filter(|ch1| str2.contains(*ch1))\n .collect::\u003cString\u003e();\n\n common_chars.as_str()\n}",
"sig": "867154f293db689c0688527b409ef8907ec7d7d8a8a43a22c7d7862bc5301060bd249014d845e00f280350ebbd9f06b10d2554d1e70796e7c7837aeecb05815b"
}