I hereby claim:
- I am sam0x17 on github.
- I am sam0x17 (https://keybase.io/sam0x17) on keybase.
- I have a public key ASD59tnchzvt33Gvmfz_J-ooAwmgcVE5dopA3Nkd9RgNrwo
To claim this, I am signing this object:
| #!/bin/sh | |
| brew update | |
| brew upgrade | |
| brew install postgresql | |
| createuser -s postgres | |
| brew services start postgresql |
I hereby claim:
To claim this, I am signing this object:
| trait RawBytes: Sized { | |
| fn raw_bytes(&self) -> &[u8] { | |
| let ptr = self as *const Self as *const u8; | |
| unsafe { core::slice::from_raw_parts(ptr, std::mem::size_of::<Self>()) } | |
| } | |
| } | |
| impl<T> RawBytes for T {} |
| let const_fns: Vec<TraitItemFn> = const_fns | |
| .into_iter() | |
| .map(|item| match item { | |
| TraitItem::Fn(trait_item_fn) => Ok(*trait_item_fn), | |
| _ => return Err(Error::new(item.span(), "expected `fn`")), | |
| }) | |
| .collect::<std::result::Result<_, Self::Error>>()?; |
| pub const fn const_str_eq(a: &str, b: &str) -> bool { | |
| if a.as_bytes().len() != b.as_bytes().len() { | |
| return false; | |
| } | |
| let mut i = 0; | |
| while i < a.as_bytes().len() { | |
| if a.as_bytes()[i] != b.as_bytes()[i] { | |
| return false; | |
| } | |
| i += 1; |
| macro_rules! assert_impl { | |
| ($typ:ty, $($trait:path),*$(,)?) => { | |
| { | |
| const fn _assert_impl<T>() | |
| where | |
| T: $($trait +)* ?Sized, | |
| {} | |
| _assert_impl::<$typ>(); | |
| } | |
| } |
mod some_mod;Simply means "there exists some file called some_mod.rs in this directory, or there exists some directory called some_mod in this directory that contains a file called mod.rs. Typing this line will make whatever content contained within the file (some_mod/mod.rs or some_mod.rs) available in this file via some_mod::whatever.
So Rust source files are modules. There is also a handy inline syntax for defining a short sub-module in the current file/module without needing to have a separate file for this module. This syntax is the source of confusion for a lot of people as it makes them think they have to write mod some_mod { to define any modules. Nope, this is just an inline shortcut for making a separate file and putting stuff in there, like the following:
mod some_other_mod {
// stuff in here| pub trait GenericStr { | |
| fn as_str_generic(&self) -> &str; | |
| } | |
| impl GenericStr for &String { | |
| fn as_str_generic(&self) -> &str { | |
| self.as_str() | |
| } | |
| } |
| #!/bin/bash | |
| set -ex | |
| # run updates, clean unneeded packages | |
| sudo apt-get update --assume-yes | |
| sudo apt-get upgrade --assume-yes | |
| sudo apt-get remove --assume-yes libreoffice-* | |
| # fix repo issue | |
| sudo add-apt-repository -r ppa:ubuntu-toolchain-r/test |
| [build] | |
| rustc-wrapper = "/home/sam/.cargo/bin/sccache" | |
| [profile.rust-analyzer] | |
| inherits = "dev" |