@@ -15,9 +15,8 @@ use std::{
1515///
1616/// # Arguments
1717///
18- /// * `before` - The text to display before prompting for input.
18+ /// * `before` - The text to display before prompting for input. Add here `\n` for a new line.
1919/// * `allow_empty` - If true, allows the input to be empty.
20- /// * `new_line` - If true, adds a newline character after the prompt.
2120///
2221/// # Returns
2322///
@@ -29,20 +28,20 @@ use std::{
2928/// ```no_run
3029/// use console_utils::input;
3130///
32- /// let user_input = input::<String>("Enter something: ", false, false );
31+ /// let user_input = input::<String>("Enter something: ", false);
3332///
3433/// match user_input {
3534/// Some(value) => println!("You entered: {}", value),
3635/// None => panic!("The Input cannot be None, allow_empty is false."),
3736/// }
3837/// ```
39- pub fn input < T > ( before : & str , allow_empty : bool , new_line : bool ) -> Option < T >
38+ pub fn input < T > ( before : & str , allow_empty : bool ) -> Option < T >
4039where
4140 T : std:: str:: FromStr ,
4241 T :: Err : std:: fmt:: Debug ,
4342{
4443 loop {
45- print ! ( "{before} {}" , if new_line { '\n' } else { '\0' } ) ;
44+ print ! ( "{before}" ) ;
4645 io:: stdout ( ) . flush ( ) . unwrap ( ) ;
4746
4847 let mut cli = String :: new ( ) ;
@@ -259,26 +258,21 @@ pub fn spinner(mut time: f64, spinner_type: SpinnerType) {
259258///
260259/// # Arguments
261260///
262- /// * `str` - The string to reveal gradually.
261+ /// * `str` - The string to reveal gradually. Add here `\n` for a new line.
263262/// * `time_between` - The time interval (in seconds) between each revealed character.
264- /// * `new_line` - If true, adds a newline character after the revelation.
265263///
266264/// # Example
267265///
268266/// ```rust
269267/// use console_utils::reveal;
270268///
271269/// // Display "Hello World!" with a time interval of 0.1 seconds between each character and a new line after it's finished.
272- /// reveal("Hello World!", 0.1, true );
270+ /// reveal("Hello World!", 0.1);
273271/// ```
274- pub fn reveal ( str : & str , time_between : f64 , new_line : bool ) {
272+ pub fn reveal ( str : & str , time_between : f64 ) {
275273 for i in 0 ..str. len ( ) {
276- print ! ( "{}" , str . chars( ) . nth( i) . unwrap( ) ) ;
274+ print ! ( "{:? }" , str . chars( ) . nth( i) . unwrap( ) ) ;
277275 io:: stdout ( ) . flush ( ) . unwrap ( ) ;
278276 thread:: sleep ( Duration :: from_secs_f64 ( time_between) ) ;
279277 }
280-
281- if new_line {
282- println ! ( ) ;
283- }
284278}
0 commit comments