aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromagdy <omar.professional8777@gmail.com>2025-07-15 01:23:54 +0300
committeromagdy <omar.professional8777@gmail.com>2025-07-15 01:23:54 +0300
commit5a9c0c9a6c774bd9670b8fab8a1cce84c497516c (patch)
tree3bf5f40093b4003613be21aa381745b715794bd3
parentaa53605153722a3c68527ca30c33ddf89b422522 (diff)
downloadredis-rust-5a9c0c9a6c774bd9670b8fab8a1cce84c497516c.tar.xz
redis-rust-5a9c0c9a6c774bd9670b8fab8a1cce84c497516c.zip
codecrafters submit [skip ci]
-rw-r--r--codecrafters.yml2
-rw-r--r--src/main.rs9
2 files changed, 5 insertions, 6 deletions
diff --git a/codecrafters.yml b/codecrafters.yml
index 83a3898..99234a0 100644
--- a/codecrafters.yml
+++ b/codecrafters.yml
@@ -2,7 +2,7 @@
#
# These can be VERY verbose, so we suggest turning them off
# unless you really need them.
-debug: false
+debug: true
# Use this to change the Rust version used to run your code
# on Codecrafters.
diff --git a/src/main.rs b/src/main.rs
index 464716f..5c89f41 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,11 +10,10 @@ fn main() {
for stream in listener.incoming() {
match stream {
Ok(mut stream) => {
- let mut buf = [0; 128];
- stream.read(&mut buf).unwrap();
- let request = str::from_utf8(&buf).unwrap();
- for _ in 0..request.matches("PING").count() {
- stream.write_all(b"+PONG\r\n").unwrap();
+ let mut buf = [0; 512];
+ loop {
+ let _ = stream.read(&mut buf).unwrap();
+ stream.write(b"+PONG\r\n").unwrap();
}
}
Err(e) => {