| 116 | } |
| 117 | |
| 118 | Value IndexOf3(const StringValue& haystack, const StringValue& needle, |
| 119 | int64_t pos) { |
| 120 | if (pos > haystack.Size()) { |
| 121 | return ErrorValue{ |
| 122 | absl::InvalidArgumentError(absl::StrCat("index out of range: ", pos))}; |
| 123 | } |
| 124 | return IntValue(haystack.IndexOf(needle, pos).value_or(-1)); |
| 125 | } |
| 126 | |
| 127 | int64_t LastIndexOf2(const StringValue& haystack, const StringValue& needle) { |
| 128 | return haystack.LastIndexOf(needle).value_or(-1); |