Odak modu

Rust Programming

Task: Implement a basic program that uses ownership concepts

Task Details

In this task, students will create a simple Rust program that demonstrates the concepts of ownership, borrowing, and references. The program will take two strings as input, concatenate them, and then print the result without violating any ownership rules.

Steps

  1. Create a function called concatenate_strings that takes two string slices as arguments and returns a new String as the result of concatenating the two input strings.
  2. Inside the concatenate_strings function, create a new String called result. Use the push_str() method to append the contents of the first input string slice, followed by the second input string slice.
  3. Return the result string from the function.
  4. In the main function, create two String variables, string1 and string2, and initialize them with appropriate values.
  5. Call the concatenate_strings function with references to string1 and string2 as arguments (using string slices). Store the result in a new variable called concatenated_string.
  6. Print the concatenated_string variable to the console.
  7. Compile and run the program to ensure it works as expected.

Checklist

  1. Write the concatenate_strings function signature.
  2. Implement the concatenate_strings function.
  3. Initialize two String variables in the main function.
  4. Call the concatenate_strings function with string slices of the variables.
  5. Print the result to the console.
  6. Compile and run the program to test its functionality.
Background Pattern
Birlikte öğrenelim

Sektörde en çok aranan yazılım becerilerini kazan

Yapay zeka desteği, birebir mentörlük saatleri, canlı dersler ve senin için özel hazırlanmış içeriklerle eksiklerini tamamla, düzenli geri bildirimler al ve öğrenme sürecini en verimli hale getir.

Yunus Emre Kabakcı

Patika+ mezunu

Patika+ Fullstack Web Development Bootcamp mezunumuz Yunus Emre,

3 ay içinde Katar’dan aldığı teklif ile, global bir şirket olan Pavo Group’da işe başladı!


“İçerik zenginliği, mentor desteği, ileriye dönük bir network sağlaması ve dünyada en çok tercih edilen frameworkler üzerinden bir eğitim veriyor olması Patika+’ı tercih etmemin temel sebepleri oldu!“

Ödev

Yorumlar

Yorum yapabilmek için derse kayıt olmalısın!