As stated in Rustonomicon, Dot operator in Rush does a lot of magics for you. Namely, those are auto-referencing, auto-dereferencing, coercion UNTIL t
Suppose your struct consists of the following field:And you expose public interface to change the state of Transaction:In this case, if the method cha
Using a trait bound with an impl, we can implement methods conditionally for types that implement the specified traits. Here, we implement a method n
If you have written Rust code, you may have heard of so many great things about type state pattern. It’s where the current state of an object is kept
In the last article(https://velog.io/@migorithm/Fluent-Rust-Type-State-Pattern), I covered one way of handling type state pattern in Rust. As saf
Dispatches Dispatch is the process of selecting which implementation of a polymorphic operation (method or function) If that happens at runtime, we c
러스트에서 동일한 값을 이용해 Retry Logic 만들기.
Rust의 Type시스템은 강력하다 - 너무 강력해서, 현업코드에서도 타입시스템을 믿고 Refactoring하는 경우가 많다.가령 Enum타입은, 내부 요소로 존재하는 모든 variants들에 대해서, match clause안에서 반드시 매치되길 강제한다. 아래 코드를
In the last post, I talked about Constructor Injection. If you haven't already, make sure to check it out. We want our code to be open to extensibilit
Mutex poisoning과 그에 대한 해결법을 공유합니다.
Temporal Coupling In many Object-oriented programming languages, temporal coupling becomes an issue when an object requires methods to be called in a
When working on business core domain logic, we want to have your application code open for extension but close against modification, aka Open-closed p
Quick quiz! Guess what the output of the following code will be:If you guessed that the answer would be 44 or the code will not compile, continue read
Trait checking implementation is not provided in Rust WITHOUT cost. However, it doesn't mean that you cannot implement it. Here is how.
I was working on implementing my own DI container. I put my business logic and handlers in service layers that are talking against trait(or interface
In general, constuctor injection is good as it enables loosely coupled code. But, things start to look a bit off-putting when their constructors look
Circuit breaker is what enables preventing your application from hammering down the already-downed system. In Rust, the simplest abstraction possible
Most of your functions that's either "colored" with async or returns impl Future will return the result right away instead of delegating the returning
See the following example.Simple. All it does is just print out MyStruct with its argument abstracting away Borrow. Let's see the trait in more detail
Lifetime in Rust can be tricky. In this article, when it gets trickier will be discussed.Let's write the simplest generic trait as possbileOk, it take
Say you have domain events and some of them may need to be sent to email, slack or the like. As they share some functionality, you may be thinking of
You need to deal with incompatible interfaces given existing code bases.(The client expects to use the same interface as before)Here, I'll give a simp
Problem Say we have a characters and weapon. Each character has their own way to fight with weapon. From time to time, they change their weapon(perhap
Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class
In Rust, except for unit like enum or c-like enum with values lower than 255 where every variants are internally considered single byte value, when yo
Say you have to implement consensus algorithm.The moment you receive request, you run parse and analyze query, write the log and finally propagate the
Say you are building a cache server that has persistence feature like Redis. Everytime server spins up, you have to load the snapshot and build the ca