aboutsummaryrefslogtreecommitdiffstats
path: root/rustlings/solutions/16_lifetimes/lifetimes1.rs
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-10-02 21:53:51 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-10-02 21:53:51 -0500
commit6365466b189ef9e9f7257ecaefd5ef7643b58ba1 (patch)
tree17ba62056d6b691dd0217b0e8f1b3a5826dce0f6 /rustlings/solutions/16_lifetimes/lifetimes1.rs
parentbadfc4399714f594790d56f4d108f7e5f4605d03 (diff)
downloaddemos-6365466b189ef9e9f7257ecaefd5ef7643b58ba1.tar.gz
demos-6365466b189ef9e9f7257ecaefd5ef7643b58ba1.zip
Diffstat (limited to 'rustlings/solutions/16_lifetimes/lifetimes1.rs')
-rw-r--r--rustlings/solutions/16_lifetimes/lifetimes1.rs24
1 files changed, 0 insertions, 24 deletions
diff --git a/rustlings/solutions/16_lifetimes/lifetimes1.rs b/rustlings/solutions/16_lifetimes/lifetimes1.rs
deleted file mode 100644
index 4f56834..0000000
--- a/rustlings/solutions/16_lifetimes/lifetimes1.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// The Rust compiler needs to know how to check whether supplied references are
-// valid, so that it can let the programmer know if a reference is at risk of
-// going out of scope before it is used. Remember, references are borrows and do
-// not own their own data. What if their owner goes out of scope?
-
-fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
- // ^^^^ ^^ ^^ ^^
- if x.len() > y.len() { x } else { y }
-}
-
-fn main() {
- // You can optionally experiment here.
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn test_longest() {
- assert_eq!(longest("abcd", "123"), "abcd");
- assert_eq!(longest("abc", "1234"), "1234");
- }
-}