1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-07-13 01:20:42 +02:00
Files
.devcontainer
.github
.vscode
exercises
clippy
conversions
enums
error_handling
functions
generics
hashmaps
if
intro
iterators
lifetimes
macros
modules
move_semantics
options
primitive_types
smart_pointers
strings
structs
README.md
structs1.rs
structs2.rs
structs3.rs
tests
threads
traits
variables
vecs
README.md
quiz1.rs
quiz2.rs
quiz3.rs
src
tests
.all-contributorsrc
.editorconfig
.gitignore
.gitpod.yml
.markdownlint.yml
AUTHORS.md
CHANGELOG.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
README.md
flake.lock
flake.nix
info.toml
install.ps1
install.sh
oranda.json
shell.nix
rustlings/exercises/structs/structs1.rs

52 lines
1.0 KiB
Rust
Raw Normal View History

2019-05-25 06:39:58 -05:00
// structs1.rs
//
2019-05-25 06:39:58 -05:00
// Address all the TODOs to make the tests pass!
//
// Execute `rustlings hint structs1` or use the `hint` watch subcommand for a
// hint.
2019-05-25 06:39:58 -05:00
// I AM NOT DONE
2019-05-25 06:39:58 -05:00
struct ColorClassicStruct {
// TODO: Something goes here
}
struct ColorTupleStruct(/* TODO: Something goes here */);
#[derive(Debug)]
struct UnitLikeStruct;
2019-05-25 06:39:58 -05:00
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn classic_c_structs() {
// TODO: Instantiate a classic c struct!
// let green =
assert_eq!(green.red, 0);
assert_eq!(green.green, 255);
assert_eq!(green.blue, 0);
2019-05-25 06:39:58 -05:00
}
#[test]
fn tuple_structs() {
// TODO: Instantiate a tuple struct!
// let green =
assert_eq!(green.0, 0);
assert_eq!(green.1, 255);
assert_eq!(green.2, 0);
2019-05-25 06:39:58 -05:00
}
#[test]
fn unit_structs() {
// TODO: Instantiate a unit-like struct!
// let unit_like_struct =
let message = format!("{:?}s are fun!", unit_like_struct);
2019-05-25 06:39:58 -05:00
assert_eq!(message, "UnitLikeStructs are fun!");
2019-05-25 06:39:58 -05:00
}
}