|
| 1 | +// ignore-tidy-linelength |
| 2 | + |
| 3 | +#![feature(no_core)] |
| 4 | +#![no_core] |
| 5 | + |
| 6 | +// @is longest.json "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" |
| 7 | +// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' |
| 8 | +// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' |
| 9 | +// @count - "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 |
| 10 | +// @is - "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] |
| 11 | + |
| 12 | +// @count - "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 |
| 13 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' |
| 14 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' |
| 15 | + |
| 16 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' |
| 17 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" |
| 18 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false |
| 19 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' |
| 20 | + |
| 21 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' |
| 22 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" |
| 23 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false |
| 24 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' |
| 25 | + |
| 26 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' |
| 27 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" |
| 28 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false |
| 29 | +// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' |
| 30 | + |
| 31 | +pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str { |
| 32 | + if l.len() > r.len() { l } else { r } |
| 33 | +} |
0 commit comments