TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Refined: Simple Refinement Types for Rust

4 点作者 pierremenard4 个月前

1 comment

yencabulator3 个月前
I&#x27;m not convinced this is in practice better than a newtype with a hand-written `pub fn new(...)` that returns Option or Result. Sure, you get And&#x2F;Or from the library, but the cognitive overhead is not free!<p>Also, the post talks about how one should prefer parsers over validators, but the library `refined` actually makes you to write validators not parsers: <a href="https:&#x2F;&#x2F;docs.rs&#x2F;refined&#x2F;latest&#x2F;refined&#x2F;trait.Predicate.html" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;refined&#x2F;latest&#x2F;refined&#x2F;trait.Predicate.html</a> -- the library them combines validatators