feat: reorganize workbook into 3 tracks (core, engineering-2026, ecosystems)
This commit is contained in:
1 parent
82677455b2
commit
2e002b6176
64 files changed
+2295
-196
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#![allow(unused_variables, dead_code)]
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct TextInput {
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct TextStats {
|
||||
pub chars: usize,
|
||||
pub words: usize,
|
||||
pub lines: usize,
|
||||
}
|
||||
|
||||
pub fn analyze_text_json(input_json: &str) -> Result<String, String> {
|
||||
todo!("Deserializuj TextInput z JSON, policz chars/words/lines i zserializuj TextStats do JSON")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn processes_json_boundary_for_js_interop() {
|
||||
let raw = r#"{"text":"Rust\nin browser"}"#;
|
||||
let out_json = analyze_text_json(raw).unwrap();
|
||||
let stats: TextStats = serde_json::from_str(&out_json).unwrap();
|
||||
assert_eq!(
|
||||
stats,
|
||||
TextStats {
|
||||
chars: 15,
|
||||
words: 3,
|
||||
lines: 2
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_error_on_invalid_json() {
|
||||
assert!(analyze_text_json("{invalid").is_err());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user