1. Functional Programming
2. Agenda
3. Recall: AddressBook
4. Borrowing
Reference to variable
5. Memory Safety
Correct handling of references
6. Dangling Pointers
Referring to a freed object
Reference to variable
Correct handling of references
Referring to a freed object

你好,我是悦创。今天我们一起来学习 Rust 中的枚举(enum)和模式匹配(pattern matching)。
枚举是 Rust 中非常重要的复合类型,也是最强大的复合类型之一,广泛用于属性配置、错误处理、分支流程、类型聚合等场景中。学习完这节课后,你会对 Rust 的地道风格有新的认识。

你好,我是悦创。今天我们来学习 Rust 中的复合类型——结构体。
结构体是由其他的基础类型或复合类型组成的,当它所有字段同时实例化后,就生成了这个结构体的实例。在 Rust 中,结构体使用 struct 关键字进行定义。

你好,我是悦创,今天我们来认识一下 Rust 中和我们打交道最频繁的朋友——字符串。
这节课我们把字符串单独拿出来讲,是因为字符串太常见了,甚至有些应用的主要工作就是处理字符串。比如 Web 开发、解析器等。而 Rust 里的字符串内容相比于其他语言来说还要多一些。是否熟练掌握 Rust 的字符串的使用,对 Rust 代码开发效率有很大影响,所以这节课我们就来重点攻克它。

你好,我是悦创。今天我们继续探讨 Rust 中所有权这一关键设计。
上节课我们了解了计算机内存结构知识,理解了 Rust 在内存资源管理上特立独行的设计——所有权,也知道了 Rust 准备采用所有权来重构整个软件体系。那么这节课我们继续学习所有权的相关内容——借用与引用,学完这节课我们就会对 Rust 语言的所有权方案有一个相对完整的认知了。

摘要
本文深入讲解了 Rust 语言中的所有权概念以及栈与堆的管理。首先介绍了 Rust 中的值分为固定尺寸和非固定尺寸两类,以及不同编程语言对数字类型的处理差异。随后,详细解释了栈和堆的概念,以及它们在程序中的作用和区别。文章还提到了栈帧与堆空间资源的关系,以及内存泄漏问题。最重要的是,文章详细阐述了 Rust 中的所有权概念,包括所有权的基础规则和作用域,以及通过具体例子展示了在 Rust 中变量赋值时的所有权转移特性。通过这些内容的讲解,读者可以更好地理解 Rust 语言中的资源管理和内存管理机制。文章的深入讲解有助于读者更全面地理解 Rust 语言的特性和设计理念。文章还提到了 Rust 中的所有权概念,包括所有权的基础规则和作用域,以及通过具体例子展示了在 Rust 中变量赋值时的所有权转移特性。通过这些内容的讲解,读者可以更好地理解 Rust 语言中的资源管理和内存管理机制。

你好,我是悦创。今天是我们的 Rust 入门与实战第一讲。
无论对人,还是对事儿,第一印象都很重要,Rust 也不例外。今天我们就来看一看 Rust 给人的第一印象是什么吧。其实 Rust 宣称的安全、高性能、无畏并发这些特点,初次接触的时候都是感受不到的。第一次能直观感受到的实际是下面这些东西。

你好,我是悦创。欢迎加入《Rust 语言从入门到实战》,开启一段全新的学习旅程。
2018 年我开始接触 Rust,到现在已经 6 年多了,从拥护者到布道者,一直在学习积累。
Aufgabe 11: Prim- und Mirpzahlen und Primzahlpalindrome
Eine natürliche Zahl n heißt Mirpzahl, wenn sie eine Primzahl ist und wenn ihre Umkehr-zahl (die sich ergibt, wenn man die dezimale Darstellung von n rückwärts liest) nicht gleich n und ebenfalls prim ist. Beispiele für Mirpzahlen sind 13, 31, 17, 71, 359 und 953. 23 ist zwar eine Primzahl, aber keine Mirpzahl, denn 32=25. (Vorsicht: Die „Umkehrzahl“ kann also gerade und sogar eine Zweierpotenz sein, d.h. keine ungeraden Primfaktoren besitzen!)
This set of exercises is Assessed Coursework, constituting 25% of the final mark for this course. It is due on Wednesday, 10 January 2024 at 4:00pm (GMT).
The work should be yours only. You may not work in groups or even discuss these problems with anyone else. You have to upload your work on Moodle at the Gradescope links that will be provided. By submitting your solutions, you would be confirming that you have read and understood the School’s rules on Plagiarism and Assessment Offences, which can be found here and here.
In this assignment you will select a data set and do some munging and analysis of it using pandas, Jupyter Notebooks, and associated Python-centric data science tools.
Import the core data science libraries:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
The Cache Project Part 1: Main Memory
Due Sunday, December 3
The first part of the project is to simulate main memory (RAM) in C. In this simulated system, data is written to and read from the main memory as entire 8-word cache lines, not individual words (which are 64 bits).
Aufgabe 8: Fibonacci-Zahlen — Iteration und Rekursion
Die i-te Fibonacci-Zahl wird definiert durch:
fi:=⎩⎨⎧01fi−1+fi−2fu¨r i=0fu¨r i=1fu¨r i≥2
Assignment 3
Due Tuesday, November 21 at 11:55pm
ith an automatic extension to Sunday, November 26 at 11:55pm
This is an assembly language programming assignment in which you have to write assembly code for inserting nodes containing employee information into a binary search tree and for removing nodes from the tree.
Aufgabe 6: Gleitkommazahlen
Auf einem fiktiven Computer seien alle darstellbaren reellen Zahlen, genannt Gleitkomma-zahlen (GKZ) ,in dem 8-bit GKZ-Format R(2,5,−1,+2) speicherbar. In diesem binären Format werden 1 bit für das Vorzeichenbit s, 2 bit für den Exponenten e zur Basis 2 im Bereich −1, . . . , +2 (welcher um 1 nach oben verschoben, d.h. nichtnegativ gespeichert wird) und 5 bit für die Mantisse m=0.m1m2m3m4m5 einer Gleitkommazahl x verwendet:
A little assignment to practice importing and analyzing data within a MongoDB database.
The goals of this assignment are to:
Please submit your solutions to these questions on Gradescope in a PDF file.
(a) Explain how to implement a queue using two stacks. Analyse the running time of the queue operations enqueue and dequeue.
(b) Explain how to implement a stack using two queues. Analyse the running time of the stack operations pop and push.
Please submit the solutions to these questions on Gradescope in two separate Python files: LinkedList.py and SortedDLL.py.
Consider the implementation of a singly linked list LinkedList.py, discussed in the lecture and available from Moodle. This implementation just has a head pointer. It also comes with just two methods: isEmpty(self) and add(self,item). The first one checks whether the linked list is empty; the latter one adds an item at the front of the linked list.