MCPcopy Index your code
hub / github.com/endbasic/endbasic / exec

Method exec

std/src/strings.rs:181–208  ·  view source on GitHub ↗
(&self, scope: Scope<'_>)

Source from the content-addressed store, hash-verified

179 }
180
181 fn exec(&self, scope: Scope<'_>) -> CallResult<()> {
182 debug_assert_eq!(1, scope.nargs());
183 let s = scope.get_string(0);
184
185 let mut chars = s.chars();
186 let ch = match chars.next() {
187 Some(ch) => ch,
188 None => {
189 return Err(CallError::Syntax(
190 scope.get_pos(0),
191 format!("Input string \"{}\" must be 1-character long", s),
192 ));
193 }
194 };
195 if chars.next().is_some() {
196 return Err(CallError::Syntax(
197 scope.get_pos(0),
198 format!("Input string \"{}\" must be 1-character long", s),
199 ));
200 }
201 let ch = if cfg!(debug_assertions) {
202 i32::try_from(ch as u32).expect("Unicode code points end at U+10FFFF")
203 } else {
204 ch as i32
205 };
206
207 scope.return_integer(ch)
208 }
209}
210
211/// The `CHR` function.

Callers

nothing calls this directly

Calls 15

char_index_to_byte_indexFunction · 0.85
byte_index_to_char_indexFunction · 0.85
char_lenFunction · 0.85
slice_by_char_rangeFunction · 0.85
format_booleanFunction · 0.85
format_doubleFunction · 0.85
format_integerFunction · 0.85
parse_numeric_prefixFunction · 0.85
get_stringMethod · 0.80
charsMethod · 0.80
get_posMethod · 0.80
return_integerMethod · 0.80

Tested by

no test coverage detected