-
Notifications
You must be signed in to change notification settings - Fork 0
Rust
If rust fails to build a dependency with:
Could not find directory of OpenSSL installation, and this
-syscrate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set theOPENSSL_DIRenvironment variable for the compilation process.
install the openssl headers sudo dnf install openssl-devel
rust-analyzer by default will cargo check with --all-targets, causing a check error for cfg(test).
Another thing is that the peripherals are generated by a macro, which in turn depends on a specific feature for a specific chip.
To prevent both, set rust-analyzer.cargo.allTargets=false in the LSP config.
https://github.com/AllexVeldman/techwiki/wiki/(neo)vim#per-project-settings
This does not solve rust-analyzer resolving the wrong return type for esp_hal::init() which, according to rust-analyzer, resolves to esp32h2::Peripherals while in reality it resolves to esp_hal::peripherals::Peripherals.
You can't define a Trait and derive for that trait in the same crate, the macro needs a crate on its own.
If the derive macro needs the Trait it impls, for example calling the trait on sub-structs, you need to refer to the Trait by its public name.
within the crate defining the Trait this would result in a use of unresolved module or unlinked crate error.
To resolve this, put the Trait in its own crate, or add pub extern crate self as <public name of the crate>; to lib.rs.
Traits and derive macros are tracked separalty by rust, so adding a derive with the same name in the Trait module would resolve to both:
// Ensure a `use pyrepr::PyRepr` exposes both the Trait and the derive macro
pub use pyrepr_derive::PyRepr;To doctest this with the Trait, you also need to add the extern crate there:
/// Trait used for structs/enums to show a Python __repr__
///
/// This Trait can be derived for structs/enums with named fields.
///
/// ```
/// # extern crate my_crate;
/// # fn main(){
/// use pyrepr_derive::PyRepr;
///
/// #[derive(PyRepr)]
/// struct MyStruct{
/// field1: u32,
/// foo: f64,
/// }
///
/// let x = MyStruct{field1:1, foo:4.2};
/// assert_eq!(x.repr(), "MyStruct(field1=1, foo=4.2)");
///
/// # }
/// ```
pub trait PyRepr {
fn repr(&self) -> String;
}