changed some calculator stuff idk
idk
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
- provides a simple trait to standardise the way applications are called and run from the shell or other applications.
|
||||
|
||||
```rust
|
||||
use async_trait::async_trait;
|
||||
|
||||
// all applications should implment this trait and be started by using simlar to:
|
||||
let res = ImplementsApplication.run(args).await?;
|
||||
|
||||
#[async_trait]
|
||||
pub trait Application {
|
||||
fn new -> Self;
|
||||
|
||||
async fn run(&mut self, _: Vec<String>) -> Result<(), Error>;
|
||||
}
|
||||
```
|
||||
## important:
|
||||
- the async_trait crate must be in scope in the file or else an error about trait bounds will be displayed at compile time.
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
- provides structs and functions for input and output
|
||||
|
||||
provided features:
|
||||
|
||||
```rust
|
||||
print() // prints a formatted string to the screen
|
||||
println!() // print with a newline appended
|
||||
|
||||
print_log!() // prints a formatted log string in yellow
|
||||
println_log!() // print_log with newline appended
|
||||
|
||||
printerr!() // prints formatted error in yellow with appended newline, this is called when the OS panics.
|
||||
|
||||
impl Screen {
|
||||
pub fn terminal_mode(); // changes the display mode of the kernel to terminal mode, meaning text can be inputted line by line as commands.
|
||||
pub fn application_mode(); // changes the display mode of the kernel to application mode, meaning applications are responsible for generating their own frames and rendering them.
|
||||
pub fn switch(); // toggles the current display mode
|
||||
pub fn clear(); // clears the screen
|
||||
}
|
||||
|
||||
impl Stdin {
|
||||
pub async fn readline() -> String; // reads a line of input in terminal mode
|
||||
pub async fn keystroke() -> char; // waits for the user to enter a keystroke
|
||||
pub fn try_keystroke() -> Option<char>; // immediately returns a keystroke if an unread one has been received by the kernel
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,6 @@
|
||||
```rust
|
||||
impl Random {
|
||||
pub fn int(lower: usize, upper: usize) -> usize; // returns random number in range
|
||||
pub fn selection<T: Clone>(ls: &Vec<T>)
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user