Initial commit

This commit is contained in:
Jeehoon Kang
2022-08-16 00:24:21 +09:00
commit 1cd733355d
10 changed files with 204 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
//! Assignment 1: Preparing for Rust Development Environment.
//!
//! The primary goal of this assignment is bringing up SSH, VSCode, and all the other necessary tools to develop Rust programs.
//! Please make sure you're comfortable with developing Rust programs before moving on to the next assignments.
//!
//! You should fill out `add()` and `sub()` function bodies in such a way that `/scripts/grade-01.sh` works fine.
//! See `assignment01_grade.rs` and `/scripts/grade-01.sh` for the test script.
//!
//! Hint: https://doc.rust-lang.org/std/primitive.usize.html
/// Adds two unsigned words. If overflow happens, just wrap around.
pub(crate) fn add(lhs: usize, rhs: usize) -> usize {
todo!()
}
/// Adds two unsigned words. If underflow happens, just wrap around.
pub(crate) fn sub(lhs: usize, rhs: usize) -> usize {
todo!()
}

View File

@@ -0,0 +1,24 @@
#[cfg(test)]
mod test {
use super::super::assignment01::*;
#[test]
fn add_7_3() {
assert_eq!(add(7, 3), 10);
}
#[test]
fn add_overflow() {
assert_eq!(add(usize::MAX, 1), usize::MIN);
}
#[test]
fn sub_7_3() {
assert_eq!(sub(7, 3), 4);
}
#[test]
fn sub_underflow() {
assert_eq!(sub(usize::MIN, 1), usize::MAX);
}
}

5
src/assignments/mod.rs Normal file
View File

@@ -0,0 +1,5 @@
#![allow(dead_code)]
#![allow(unused_variables)]
mod assignment01;
mod assignment01_grade;

33
src/lib.rs Normal file
View File

@@ -0,0 +1,33 @@
//! KAIST CS220: Programming Principles
// # Tries to deny all lints (`rustc -W help`).
#![deny(absolute_paths_not_starting_with_crate)]
#![deny(anonymous_parameters)]
#![deny(box_pointers)]
#![deny(deprecated_in_future)]
#![deny(explicit_outlives_requirements)]
#![deny(keyword_idents)]
#![deny(macro_use_extern_crate)]
#![deny(missing_debug_implementations)]
#![deny(non_ascii_idents)]
#![deny(pointer_structural_match)]
#![deny(rust_2018_idioms)]
#![deny(trivial_numeric_casts)]
#![deny(unaligned_references)]
// #![deny(unused_crate_dependencies)] // TODO: uncomment
#![deny(unused_extern_crates)]
#![deny(unused_import_braces)]
#![deny(unused_qualifications)]
#![deny(unused_results)]
#![deny(variant_size_differences)]
#![deny(warnings)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::missing_doc_code_examples)]
#![deny(missing_docs)]
#![deny(rustdoc::all)]
#![deny(unreachable_pub)]
#![deny(single_use_lifetimes)]
#![deny(unused_lifetimes)]
#![deny(unstable_features)]
mod assignments;