- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Hyper 0.11,它可以重新导出箱子“mime”。我正在尝试从字符串创建 MIME 类型:
extern crate hyper;
fn main() {
let test1 = hyper::mime::Mime::from_str("text/html+xml").unwrap();
}
错误:
error[E0599]: no function or associated item named `from_str` found for type `hyper::<unnamed>::Mime` in the current scope
为什么会出现这个错误,是什么原因造成的?如何解决?
最佳答案
你得到这个错误是因为,果然,Mime
上没有定义from_str
方法。 .为了解析像 Mime::from_str
这样的名称,from_str
必须是 Mime
的固有方法(不是特征的一部分) ,或者在使用它的地方范围内的特征的一部分。 FromStr
不在范围内,因此您会收到错误消息——尽管错误消息会告诉您出了什么问题以及如何解决:
error[E0599]: no function or associated item named `from_str` found for type `hyper::<unnamed>::Mime` in the current scope
--> src/main.rs:3:13
|
3 | let test1 = hyper::mime::Mime::from_str("text/html+xml").unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use std::str::FromStr;`
但是,在这种特殊情况下,更常见的做法是使用FromStr
,而不是直接调用from_str
,而是通过parse
间接调用from_str
。 str
上的方法,如 FromStr
's documentation提及。
let test1: hyper::mime::Mime = "text/html+xml".parse().unwrap();
关于rust - 找不到类型 `from_str` 的名为 `hyper::mime::Mime` 的函数或关联项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48655891/
这个问题在这里已经有了答案: Is Git’s "master" branch name more than just a name? (3 个回答) What will break if I don
我使用了Plone实例文件夹的“bin /”目录中的“paster”命令来创建一个名为“MyApp”的plone应用程序(来自模板),该命令是: (from instance's root folde
我正在尝试覆盖 FOSUserBundle 的用户映射的两个属性。 use FOS\UserBundle\Model\User as BaseUser; ... use Symfony\Bridge\
工作通过 these posts让我认为我了解自我类型,至少在某种程度上。 所以我创建了一个按预期失败的例子: scala> trait A { val v = "a" } defined trait
我在 IntelliJ 中有一个 JavaFX Maven 项目,它使用 Hibernate。当应用程序启动时,我收到以下错误消息: No persistence provider for entit
我正在尝试构建一个数据透视表,并使用开源代码并摸索着这个函数。record[] 如何传递给这个函数?似乎没有经过或任何声明。怎么能直接来呢? 完整代码可以在这里找到https://github.com
我的应用程序有 abc.com 链接,这是一个主页和 abc.com/user123(有一个动态部分),这是一个用户登录的特定配置文件页面。 早些时候,我通过这样做实现了这一点: this.route
当我在使用 mac book pro 的 Android Studio 上设置 Flutter Sdk 路径时,我遇到错误 Flutter SDK 路径未给出(并且打开一个弹出窗口并显示消息“名为‘F
我刚刚设置了 Postgres 供我网络上的不同用户使用。每个用户都有自己的用户名/密码/数据库,但是当我连接到 Pg 时,我还可以看到一个“postgres”数据库(甚至可以创建表等)。我试图从公众
我正在尝试从 MySQL 数据库中获取一些数据。所以我要做的是: select * from my_table where 'to' ='0000-00-00 00:00:00'; 这给了我空集,但我
我有一个名为“索引”的表。我意识到这是 MySQL 中的关键字,想知道如何在查询中引用该表? 我的错误: #1064 - You have an error in your SQL syntax; c
我在机器 myuniversity.edu 上设置了一个远程 mysql 数据库服务器,服务器名为“localhost”。我在上面有一个名为“MyDatabase”的数据库。 I want to co
我正在尝试使用 Android NDK 构建应用程序。我已按照所有步骤操作,一切正常,正在制作 .so 文件。但是在 Eclipse 中,当我尝试清理项目时出现以下错误: The file does
我正在重写 UIImage 类方法 init(named:)。我的目标是能够检索图像的文件名。 代码看起来像这样: class UIImageWithFileName: UIImage { l
@ThreadSafe public class A { } 这个注解实际上使类线程安全还是只是为了提高可读性? 最佳答案 参见 @ThreadSafe Annotation : Place this
当我将第二个表(dtResult)添加到数据集时出现错误 名为“Table”的数据表已属于此数据集。 DataTable dtSession = new DataTable(); DataTable
这个问题可能看起来重复,但略有不同。在 SO 的所有其他问题中,我注意到他们注册了多条路线。但就我而言,我只有一条路线。 我正在创建 asp.net webapi(框架 4.5)并且在 Registe
我最近将 Microsoft.AspNet.WebApi.WebHost 添加到 MVC WebAPI 项目中,这将允许我使用 [Route("api/some-action")] 归因于我的行动。我
我有一个名为“异常”的命名空间的问题 让我们考虑以下示例标题: #include namespace exception { struct MyException : public std::e
我昨天安装了 Nuget 1.2,今天,当我尝试安装 Entity Framework 包时,我在包管理器控制台中遇到了以下问题: PM> install-package entityframewor
我是一名优秀的程序员,十分优秀!