Committing a set of basic rust examples.
This contains code and tests for several basic rust skills.
This commit is contained in:
59
README.md
59
README.md
@ -1,14 +1,67 @@
|
||||
# example
|
||||
# Example
|
||||
|
||||
Just a small sample of Rust code.
|
||||
A lightweight collection of examples demonstrating essential Rust features,
|
||||
without relying on external dependencies (except `tokio`).
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Concepts Covered
|
||||
|
||||
- Arrays and Iteration
|
||||
- Lifetimes and Borrowing
|
||||
- Error Handling with `Result`, `?`, and custom messages
|
||||
- Async Programming using `#[tokio::main]`
|
||||
- File I/O with the standard library
|
||||
- Unit and async testing
|
||||
|
||||
### Key Functions
|
||||
|
||||
| Function | Description |
|
||||
|------------------|--------------------------------------------------------|
|
||||
| `longest` | Returns the longest string in a slice without copying. |
|
||||
| `read_and_parse` | Reads a file and parses its content into an integer. |
|
||||
| `run_tasks` | Demonstrates spawning and awaiting async tasks. |
|
||||
|
||||
### Testing
|
||||
|
||||
Includes both synchronous and asynchronous unit tests under a
|
||||
`#[cfg(test)]` module.
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Testing & Extending
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
- Rust 1.76+ (for full language support)
|
||||
- [Tokio 1.37+](https://docs.rs/tokio) (for async runtime)
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Project Structure
|
||||
|
||||
```text
|
||||
src/
|
||||
├── info.rs # Crate information from Cargo.
|
||||
├── main.rs # Foundational examples.
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Copyright & License
|
||||
|
||||
Copyright 2025 CyberMages LLC
|
||||
Copyright 2025 Jason Travis Smith
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this library except in compliance with the License.
|
||||
|
Reference in New Issue
Block a user