サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
iPhone 16
hermanradtke.com
Russian Translation In my last post we talked a lot about using &str as the preferred type for functions accepting a string argument. Towards the end of that post there was some discussion about when to use String vs &str in a struct. I think this advice is good, but there are cases where using &str instead of String is not optimal. We need another strategy for these use cases. A struct Containing
Russian Translation We learned how to create a function that accepts String or &str as an argument. Now I want to show you how to create a function that returns either String or &str. I also want to discuss why we would want to do this. To start, let us write a function to remove all the spaces from a given string. Our function might look something like this: fn remove_spaces(input: &str) -> Strin
If you have spent any amount of time learning Rust, you quickly become accustomed to Option and Result types. It is through these two core types that we make our programs reliable. My background is with C and dynamic languages. I found it easiest to use the match keyword when working with these types. There are also combinator functions like map and and_then which allow a set of computations to be
In this post I am going to walk through the creation of a webservice in Rust. This is a Getting Started post that will serve as a foundation for future posts. The webservice will return a static json response to start. There are a few different options for web frameworks in Rust, but practically all of them use the underlying HTTP library called hyper. I am most familiar with nickel, so we will be
Russian Translation For all the people frustrated by having to use to_string() to get programs to compile this post is for you. For those not quite understanding why Rust has two string types String and &str, I hope to shed a little light on the matter. Functions That Accept A String I want to discuss how to build interfaces that accept strings. I am an avid hypermedia fan and am obsessed about de
When building a foreign function interface to C code, we will inevitably run into a struct that has a union. Rust has no built-in support for unions, so we must come up with a strategy on our own. A union is a type in C that stores different data types in the same memory location. There are a number of reasons why someone may want to choose a union, including: converting between binary representat
I needed async IO for a Rust project I was working on. My server needs to read some bytes from a client and then send those bytes back to all registered clients. I decided to use mio, the Rust async IO library, to build a server. All the examples I found showcased reading from a socket and then writing back to that same socket. Also, many of the examples had caveats about unhandled edge cases and
In Rust, you quickly learn that vector and slice types are not iterable themselves. Depending on which tutorial or example you see first, you call .iter() or .into_iter(). If you do not realize both of these functions exist or that they do different things, you may find yourself fighting with the compiler to get your code to work. Let us take a journey through the world of iterators and figure out
このページを最初にブックマークしてみませんか?
『hermanradtke.com』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く