This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{self, Read, Write}; | |
| struct StringRW { | |
| value: String, | |
| buffer: Vec<u8>, | |
| } | |
| impl StringRW { | |
| fn new(value: &str) -> Self { | |
| StringRW { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(Debug, PartialEq, Eq, Clone)] | |
| struct Node<T: Clone> { | |
| name: String, | |
| value: T, | |
| next: Option<Box<Node<T>>> | |
| } | |
| impl<T: PartialEq + Clone> Node<T> { | |
| fn new(name: &str, value: T) -> Self { | |
| Node { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let text = "ありがとうございます"; | |
| let words = text.split("").map(|w| w.as_bytes()).collect::<Vec<&[u8]>>(); | |
| let length = words.iter().fold(0, |acc, val| acc + val.len()); | |
| println!("Input Text: {}", text); | |
| println!("Bytes: {:?}", words); | |
| println!("Text is {} bytes long", length); | |
| let mut inline_bits = String::new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Entity { | |
| fn walk(&self) -> String; | |
| } | |
| struct Dog { | |
| name: String, | |
| age: i32 | |
| } | |
| impl Dog { |