apprasial_text.as_str()
А в чем проблема загуглить? how to convert String to &str
я так делал, выбор всё равно не работает...
Был такой вариант: loop { io::stdin() .read_line(&mut appraisal_text) .expect("Ошибка чтения данных!"); match appraisal_text.as_str() { "0" => break, "1" => appraisal_count -= 200, "2" => appraisal_count -= 50, "3" => continue, "4" => appraisal_count += 25, "5" => appraisal_count += 50, "2-" => appraisal_count -= 100, "3-" => appraisal_count -= 20, "4-" => appraisal_count += 20, "5-" => appraisal_count += 35, "2+" => appraisal_count -= 50, "3+" => appraisal_count += 10, "4+" => appraisal_count += 25, "_" => {println!("Неправильный ввод!"); appraisal_text.clear(); continue;} _ => {} } println!("Вы ввели: {} и счет = {}", appraisal_text, appraisal_count); appraisal_text.clear();
Обсуждают сегодня