Creează un cont pentru a te abona la acest blog și a-i urmări articolele pe pagina Lectură.
-
A Vector in Rust is fundamentally a (pointer, capacity, length) triplet.
-
Suppose that a number $n$ has $d$ digits, then: $$ 10^{d-1} \leq n \lt 10^{d}...
-
By using generic parameters, you can `impl` a trait for any type that satisfies some trait bounds, for example, implement trait `ToString` for every type `T` that implemented the `Display` trait: ```r...
-
Rust has a special type `!
-
Before Rust 1.0, writing code that returns a reference without any lifetime annotation wouldn't compile.
-
The built-in `console` comes with the `console.assert` method, which is pretty useful to write some tests in your code.
-
Overflow can happen when doing integer arithmetics in Rust, for example: ```rust let _ = 255u8 + 1;...
-
The traits [`std::ops::Deref`](https://doc.rust-lang.org/std/ops/trait.Deref.html) and [`std::ops::DerefMut`](https://doc.rust-lang.org/std/ops/trait.DerefMut.html) are used for **explicit dereference...
-
One of the rules for working with traits in Rust is: You are not allowed to implement a trait on a type if either the trait or the type is not local to your crate.
-
Due to rounding errors, most floating-point numbers cannot be represented precisely in the computer.
-
`ArenaAllocator` is one of Zig's built-in allocators.
-
There are 4 build modes in Zig, each can be enabled via the arguments `-O ReleaseSafe`, `-O ReleaseSmall`, and `-O ReleaseFast` when running `zig run` or `zig test`.
-
A function in Zig can return either an error or an actual value, most of the time you will see something like this: ```zig pub fn countTheSheep() !
-
Zig has built-in support for JSON via the `std.json` module.
-
Implementing a stack is one of my favorite tests when working with a new language because it will show us a lot about the language's ergonomics.
-
Zig came with a built-in C/C++ compiler `zig cc` and `zig c++`.
-
One of the unique features of Zig is the ability to let us control what happens in our code, during both runtime and compile time.
-
Zig has no runtime, hence, no automatic memory management.
-
Just like C/C++, you can define a string in Zig with an array of bytes or as a null-terminated string literal.
-
In React, you can mount a component into any DOM node instead of just the current parent component, with the help of `ReactDOM.createPortal([content], [node] )`.
-
Let's say, we are building a component to display some images (with lazy loading): ```javascript const LazyImage = (props: ImageProps) => {...
-
Sometimes, you'll run into a case where TS keeps complaining about a possibly undefined value.
-
In Next.js, you can define a [dynamic route](https://nextjs.org/docs/routing/dynamic-routes) by creating a file at `/pages/post/[id].tsx`.
-
Algorithm to delete a node from a BST: - Find the node to delete - Find the deepest right most (DRM) node of the tree...
-
To create a custom widget in [Druid](https://linebender.org/druid/), we create a new struct and implement [Widget](https://docs.rs/druid/latest/druid/trait.Widget.html) trait.
-
This one is a bit more compex than the pre-order (in term of using stack).
-
When solving palindrome problems, we need to avoid sliding window solution (a.k.a brute force), where we try to generate every substring and check to find the palindrome.
-
The array **x** is to keep track of all possible integers we can find, the array **t** is to keep the sum **t[i]** of every **x** number from **x[1]** to **x[i]**.
-
The algorithm is simple: 1.
-
Like currying, if a function takes some arguments and we invoke that function without all of the arguments, a new function will be created so we can call it with the remaining functions later on.