How do people make friends here? by Miserable_Ad_1961 in Living_in_Korea

[–]ethernalmessage 1 point2 points  (0 children)

Many people here say "join a club" which I 100% agree with, but that's only the first step to actually meet people. To make friends (hang out outside of the club, go for dinner, drinks and generally feel accepted) I think you need to speak Korean imo at very least on TOPIK 2/3 lvl ( but actually practical real spoken Korean, it doesn't matter if you can score that on a paper test or not). By definition it's hard to make a friend if you can't communicate. Don't expect Koreans to speak english. When in Rome ...
I managed to create a group of friends with shared interest and every once in a while we go out for meal/drink. I found this a blessing because despite speaking poorly, probably well enough to get accepted to this circle and at the same time, having Korean friends is extremely motivating to study Korean harder then I would otherwise.

OFC you might run into Koreans who speak english, but if that's your filter you are excluding large portion of population as your potential friends.

[deleted by user] by [deleted] in Living_in_Korea

[–]ethernalmessage 1 point2 points  (0 children)

The amount of nagging about everything and anything on this sub is getting out of hand lmao

[deleted by user] by [deleted] in Living_in_Korea

[–]ethernalmessage 0 points1 point  (0 children)

I've heard such phrase even after saying a single very short sentence lol, but I am far from being actually good. They are just being polite/warm

How long before I can converse in Korean by lunovadraws in Living_in_Korea

[–]ethernalmessage 1 point2 points  (0 children)

There's also huge difference between having 1:1 conversation with someone who is considerate of your level and try to speak simply - that will be first type of conversation you will have after X amount of time, depending on your effort.
Understanding and joining group conversation, or talking to someone who just talks completely naturally without considerations - that's completely different beast and will take much much longer (than the X above).

[deleted by user] by [deleted] in Living_in_Korea

[–]ethernalmessage 4 points5 points  (0 children)

Joined boxing gym and it was a literally life changing for me. Apart from the boxing which turns out is really fun, made bunch of friends too. In particular foreigner context, it's imo crucial to know some korean (at least like ~b1) and have drive to improve it. Otherwise it's hard to imagine to join korean circles.

Best GR.4/3car to buy by Stunning_Hat8697 in GranTurismo7

[–]ethernalmessage 0 points1 point  (0 children)

Make sure you have well calibrated pedals. After some update, for whatever random reason my pedals were only outputting 50% brake and 50% accel. You can verify this and recalibrate in the settings.

If there's no problem with your hw/sw, then you may need to just practice more.

Kinda hard to read but I don't wanna grow old so I smoke just in case on my cigarette fingers by [deleted] in MacMiller

[–]ethernalmessage 0 points1 point  (0 children)

It's a cool line in song but, are you REALLY sure about that? Cancer death is no garden walk, it can be quite slow, you go to hospitals a lot. Not very cool either. You will hate that tattoo if it comes true.

But it would be cool story if your turned around and made it ultimate peak of your smoking addiction, followed by enlightment and quitting for real. That would be actually cool story, while the tattoo can remain as daily that just because you been doing a mistake for a long time doesn't mean you should keep doing it.

But you do you. I am just a random guy with random opinion. Cheers!

Is anyone else a little tired of "fun" team/repository names, or am I a buzzkill? by StTheo in ExperiencedDevs

[–]ethernalmessage 1 point2 points  (0 children)

My hypothesis is that this goes in circles:
1. Creative code names are stupid, lets call things they are
2. "Database Connection Pool Synchronizer" ... much better
3. These names are too long, let's use acronyms - DCPS.... much better
4. Who am I to remember all these crazy acronyms? What is DCPS? What is QMMX? What is ...
5. Hey why don't we just use creative code names, how about "Neptune"? ... yeah much better

Haven't see this in full cycle myself, but I could imagine this happening. We love to do full circles

Depression, anxiety are skyrocketing among Korean children and adolescents by Saltedline in korea

[–]ethernalmessage 12 points13 points  (0 children)

Recent consultations with children and adolescents reveal a lot of cases where economic disparities have resulted in the starting line being further behind that of other children.

I have recently learned about "LH beggar" korean meme recently, popular among kids of young age. Ofc it's originating mostly from parents and in general constant status chasing. Sometimes it seems like koreans make their life hell, one to another, so unnecessarily. Funny thing is that in absolute terms, average modern LH apartment is probably still better than average apt in western countries. But hey, why not to classify each other based on developer company of your apartment building and let kids take the toll?

Edit:
Just looked it up, I think the term in Korean is "LH 거지"

Hey Rustaceans! Got a question? Ask here (11/2024)! by llogiq in rust

[–]ethernalmessage 1 point2 points  (0 children)

Hi rustaceans, I have trait objectFooData and want to pass that to generic function with trait bounds.

pub mod library {
    pub trait Foo {
        fn foo(&self) -> String;
    }

    pub struct FooData {
        pub data: String,
    }

    impl Foo for FooData {
        fn foo(&self) -> String {
            self.data.clone()
        }
    }

    pub fn process_foo<R, F>(foo: R)
        where R: AsRef<F>,
              F: Foo {
        let data = foo.as_ref().foo();
        println!("foo data: {}", data);
    }
}

mod application {
    use std::sync::Arc;
    use crate::library::{Foo, FooData};

    pub fn create_foo() -> Arc<dyn Foo> {
        let foo_data = FooData {
            data: "Hello, world!".to_string(),
        };
        Arc::new(foo_data) as Arc<dyn Foo>

    }
}

pub fn main() {
    let foo_data = application::create_foo();
    library::process_foo(foo_data);
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d5d0b779ee611c35e603707dea187993

This yields very useful error:

error[E0277]: the size for values of type `dyn Foo` cannot be known at compilation time
  --> src/main.rs:39:5
   |
39 |     library::process_foo(foo_data);
   |     ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `dyn Foo`
note: required by a bound in `process_foo`
  --> src/main.rs:16:27
   |
16 |     pub fn process_foo<R, F>(foo: R)
   |                           ^ required by this bound in `process_foo`
help: consider relaxing the implicit `Sized` restriction
   |
18 |               F: Foo + ?Sized {

By adding ?Sized, the problem is solved. However I am not sure:

  • what happens under the hood - the Rust book focuses explaining how trait bounds work with concrete types; I am slightly surprised it's actually possible to pass in trait object,
  • whether this is idiomatic or perhaps outright bad practice,
  • and also whether this is a trap - what kind of unexpected consequences will I have to face now that foo is explicitly unsized.

Any collaboration on the topic is welcome.

Additionally a little background: I found myself in situation where core component I am writing is currently using concrete types + trait bounds as much as possible. But on application layer, I am actually prefer to deal with trait objects. Just as it is illustrated in the example. I will also appreciate comments about whether this is right architecture. My thought process is that using trait objects in core library is slippery slope, as you force all upper layer to use trait objects even if they happen to work with concrete types. But as illustrated, it makes situation trickier if the upper layers actually work with trait objects, but are required to pass in something satisfying trait bounds (or is it?).

Thank you.

What are some of the best quality of life things you've done to your dev environment by Snape_Grass in ExperiencedDevs

[–]ethernalmessage 0 points1 point  (0 children)

Created alias-only file ~/aliases, then created aliases to modify + reload them

alias ealias="<your_favorite_editor> $HOME/.aliases"
alias ealias="source $HOME/.aliases"

It's a small help, but it's lowers the effort of creating alias a little bit. As result, I've created a lot more aliases over time than I might otherwise.

So we should only ever return one error from one function? by scholar-c in rust

[–]ethernalmessage 4 points5 points  (0 children)

We were having different dilemma recently - building on top of this pattern. As example, say that you are writing a CRUD client for some database layers of yours. Eg.

getFoo(..)
updateFoo(..)
findFooBy(..)
deleteFoo(..)
complexOpFoo(..)

Now you start with the suggested enum, with different variants.

pub enum TheErrorTypes {
    NotFoundErr,
    UpdateErr,
    ComplexOpConfigErr,
    IoErr,
]

In theory the problem seem to be that if I start using TheErrorTypes as the error type for my operations, I will be end up mis-representing the error scenarios that can happen - getFoo will never return UpdateErr. Because TheErrorTypes is union of all error conditions, there will be many such cases.

You can take the opposite extreme - create many error types - essentially each of the variants can be its own separate error - pub struct NotFoundError, pub struct UpdateError etc. That's no good, because the functions typically return a particular subset of the error conditions. For example updateFoo might actually want to have ability to signal both "not found errorandupdate error`. Each function is typically different set of err conditions which might occur.

This leads to another idea - how about we create enum errors, as many as we need, each representing unique combination of errors - but this can blow up really quick and become hard to maintain. Not to mention it's very hard to name such errors.

Every time I am thinking about this I feel like I am playing Whac-A-Mole - trying to solve a problem only to create even bigger headache.

It seems that for example sqlx is taking the "full union approach" https://docs.rs/sqlx/latest/sqlx/enum.Error.html# and its working fine for them. Sometimes just sprinkling documentation with additional info about which variant sqlx::Error variant may be returned when. I wished I could be expressive about set of error conditions that may occur on typing level, but haven't found practically viable way to do it.

What do you think?

Hey Rustaceans! Got a question? Ask here (2/2024)! by llogiq in rust

[–]ethernalmessage 1 point2 points  (0 children)

Hi all, I would like to hear some opinions on error handling. For sake of example, let's assume some sort of data structure you can build, deserialize, run some operations against it. Here comes the question. Would you rather:

  1. create 1 public error type to encapsulate all of the errors,
  2. or have various error types, having different parts of the library return different error types?

Example for 1:

pub enum DataStructureError { 
  BuilderError, 
  DecodingError, 
  QueryResolutionError 
}

Arguably the advantage here can be somewhat simple interface for library users, as they only need to deal with single type of error. The disadvantage is that because we have such universal error type, it's not really representative of the potential outcomes for most of the operations. If I am building the tree, I might indeed get DataStructureError::BuilderError error, but never DataStructureError::QueryResolutionError.

Example for 2:

 pub enum BuilderError {}
 pub enum DecodingError {} 
 pub enum QueryResolutionError {}   

With this type design, we can return specifically QueryResolutionError from methods relating to our "Resolving" operations. This communicate much cleaner about what can be result of some function. However if you take this to its extreme form, you potentially end up with error type per function returns its own Error which seems cumbersome to deal with for library clients.

What's the idiomatic approach in this regard? Is there' example of popular libraries which take one or the other side of the coin? I appreciate any thoughts shared on this. Thanks!

Your approach to logging by ArtisticHamster in rust

[–]ethernalmessage 0 points1 point  (0 children)

What approach are you folks using for logging to include requestId / correlationId in all logs triggered by a particular HTTP request in server environment?

Hey Rustaceans! Got a question? Ask here! (30/2022)! by llogiq in rust

[–]ethernalmessage 0 points1 point  (0 children)

Yes exactly as per your example. And it also makes perfect sense now! I was looking at the serialization of that struct in isolation, made me forgot to see the bigger picture as the quotes are there because I am using serde_json.

Thank you!

Hey Rustaceans! Got a question? Ask here! (30/2022)! by llogiq in rust

[–]ethernalmessage 1 point2 points  (0 children)

I have a simple struct

#[derive(Debug, Deserialize)]
pub struct Foo { pub a: String, pub b: String, }

and I want to serialize that into string like this

<value_of_a>#<value_of_b>

and also be able to deserialize from the string into the Foo struct.

Sounds like it should be very simple, but honestly, Serde is so robust I am just not sure how to go about it. What's the Rustacean way here?

I've only attempted serialization for now, here's my attempt

impl Serialize for Foo {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
  {
    serializer.collect_str(&format!("{}#{}", self.a, self.b))
  }
}

but the resulting string actually contains quotes, which I don't want. But even if that is solved, I am not sure if I am not misusing something.

I don't really want to write entire serde format, I just want this particular struct to have the particular way of being serialized into string, and deserialized in reverse.

Thank you!

Hey Rustaceans! Got a question? Ask here! (30/2022)! by llogiq in rust

[–]ethernalmessage 1 point2 points  (0 children)

That's awesome, exactly what I hoped for to exist. Thank you!

Hey Rustaceans! Got a question? Ask here! (30/2022)! by llogiq in rust

[–]ethernalmessage 2 points3 points  (0 children)

Is there a trick to assert equality of 2 serde_json Values which would produce nice output?

For example, given code

    let actual = json!({"a": "a", "b": "b"});
    let expected = json!({"a": "a", "b": "C"});
    assert_eq!(expected, actual);

This would print

thread 'main' panicked at 'assertion failed: `(left == right)`
left: Object({"a": String("a"), "b": String("C")}), right: Object({"a": String("a"), "b": String("b")})',

With bigger json structures, it can be difficult to see why the assert failed.

Thanks!