ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

Nick::new is foolish #1370

Closed ctm closed 6 months ago

ctm commented 6 months ago

Get rid of Nick::new.

It's a wrapper around try_from:

    // TODO: THis should be removed
    pub fn new(s: String) -> Result<Self, NickError> {
        TryFrom::<&str>::try_from(&s)
    }

I don't think we gain anything from consuming the String. Perhaps I'll change my mind when I remove it and start using try_from, but I simply didn't think of try_from until I was in the middle of my disallowing Zalgoed nicknames refactor (#1342) and at the time I simply implemented try_from and moved forward using it. Now I should go back and remove the remaining (original) news.

ctm commented 6 months ago

I've done this in master. It'll go out with the next deploy. I'm still not happy with the current situation, because I foolishly implemented TryFrom<&str> rather than TryFrom<String> (and possibly TryFrom<&str> in addition). However, I'll be doing some more Nick work anyway, so I'll either clean it up as part of one of those issues or make a separate issue.