当前位置: 首页 > news >正文

WordPress 卡密购买插件网站的seo

WordPress 卡密购买插件,网站的seo,163网站源码,施工合同在哪个建设网站下载41.使用模块的函数 mod 是用于创建模块的关键字。模块是一种组织代码的方式,它可以包含函数 (fn)、结构体 (struct)、枚举 (enum)、常量 (const)、其他模块 (mod) 等。模块用于组织和封装代码,帮助将代码分割成可管理的单元。模块可以形成层次结构&…

41.使用模块的函数

  • mod 是用于创建模块的关键字。模块是一种组织代码的方式,它可以包含函数 (fn)、结构体 (struct)、枚举 (enum)、常量 (const)、其他模块 (mod) 等。
  • 模块用于组织和封装代码,帮助将代码分割成可管理的单元。模块可以形成层次结构,允许你更好地组织和管理代码。

模块的函数一般是私有的,需要使用pub关键词将其暴露

// modules1.rs
// Execute `rustlings hint modules1` or use the `hint` watch subcommand for a hint.// I AM NOT DONEmod sausage_factory {// Don't let anybody outside of this module see this!fn get_secret_recipe() -> String {String::from("Ginger")}pub fn make_sausage() {get_secret_recipe();println!("sausage!");}
}fn main() {sausage_factory::make_sausage();
}

42.暴露读取私有方法的函数的属性的模板变量,以选择性地公布部分属性(设置为pub)

// modules2.rs
// You can bring module paths into scopes and provide new names for them with the
// 'use' and 'as' keywords. Fix these 'use' statements to make the code compile.
// Execute `rustlings hint modules2` or use the `hint` watch subcommand for a hint.// I AM NOT DONEmod delicious_snacks {// TODO: Fix these use statementspub use self::fruits::PEAR as fruit;pub use self::veggies::CUCUMBER as veggie;mod fruits {pub const PEAR: &'static str = "Pear";pub const APPLE: &'static str = "Apple";}mod veggies {pub const CUCUMBER: &'static str = "Cucumber";pub const CARROT: &'static str = "Carrot";}
}fn main() {println!("favorite snacks: {} and {}",delicious_snacks::fruit,delicious_snacks::veggie);
}

43.导入默认库的宏和库函数

// modules3.rs
// You can use the 'use' keyword to bring module paths from modules from anywhere
// and especially from the Rust standard library into your scope.
// Bring SystemTime and UNIX_EPOCH
// from the std::time module. Bonus style points if you can do it with one line!
// Execute `rustlings hint modules3` or use the `hint` watch subcommand for a hint.// I AM NOT DONE// TODO: Complete this use statement
use std::time::SystemTime;
use std::time::UNIX_EPOCH;fn main() {match SystemTime::now().duration_since(UNIX_EPOCH) {Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()),Err(_) => panic!("SystemTime before UNIX EPOCH!"),}
}

44.new一个hashMap

HashMap::new()

注意末尾条件,添加足够种类和数量水果即可

// hashmaps1.rs
// A basket of fruits in the form of a hash map needs to be defined.
// The key represents the name of the fruit and the value represents
// how many of that particular fruit is in the basket. You have to put
// at least three different types of fruits (e.g apple, banana, mango)
// in the basket and the total count of all the fruits should be at
// least five.
//
// Make me compile and pass the tests!
//
// Execute `rustlings hint hashmaps1` or use the `hint` watch subcommand for a hint.// I AM NOT DONEuse std::collections::HashMap;fn fruit_basket() -> HashMap<String, u32> {let mut basket = HashMap::new();// TODO: declare your hash map here.// Two bananas are already given for you :)basket.insert(String::from("banana"), 2);// TODO: Put more fruits in your basket here.basket.insert("666".to_string(),3);basket.insert("999".to_string(),1);basket
}#[cfg(test)]
mod tests {use super::*;#[test]fn at_least_three_types_of_fruits() {let basket = fruit_basket();assert!(basket.len() >= 3);}#[test]fn at_least_five_fruits() {let basket = fruit_basket();assert!(basket.values().sum::<u32>() >= 5);}
}

45.hashmap的基础插入操作

注意末尾测试的要求即可

// hashmaps2.rs// A basket of fruits in the form of a hash map is given. The key
// represents the name of the fruit and the value represents how many
// of that particular fruit is in the basket. You have to put *MORE
// THAN 11* fruits in the basket. Three types of fruits - Apple (4),
// Mango (2) and Lychee (5) are already given in the basket. You are
// not allowed to insert any more of these fruits!
//
// Make me pass the tests!
//
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a hint.// I AM NOT DONEuse std::collections::HashMap;#[derive(Hash, PartialEq, Eq)]
enum Fruit {Apple,Banana,Mango,Lychee,Pineapple,
}fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {let fruit_kinds = vec![Fruit::Apple,Fruit::Banana,Fruit::Mango,Fruit::Lychee,Fruit::Pineapple,];for fruit in fruit_kinds {// TODO: Put new fruits if not already present. Note that you// are not allowed to put any type of fruit that's already// present!}
}#[cfg(test)]
mod tests {use super::*;fn get_fruit_basket() -> HashMap<Fruit, u32> {let mut basket = HashMap::<Fruit, u32>::new();basket.insert(Fruit::Apple, 4);basket.insert(Fruit::Mango, 2);basket.insert(Fruit::Lychee, 5);// at_least_five_types_of_fruits 种类>=5// greater_than_eleven_fruits  总数 >=1basket.insert(Fruit::Banana, 5);basket.insert(Fruit::Pineapple, 5);basket}#[test]fn test_given_fruits_are_not_modified() {let mut basket = get_fruit_basket();fruit_basket(&mut basket);assert_eq!(*basket.get(&Fruit::Apple).unwrap(), 4);assert_eq!(*basket.get(&Fruit::Mango).unwrap(), 2);assert_eq!(*basket.get(&Fruit::Lychee).unwrap(), 5);}#[test]fn at_least_five_types_of_fruits() {let mut basket = get_fruit_basket();fruit_basket(&mut basket);let count_fruit_kinds = basket.len();assert!(count_fruit_kinds >= 5);}#[test]fn greater_than_eleven_fruits() {let mut basket = get_fruit_basket();fruit_basket(&mut basket);let count = basket.values().sum::<u32>();assert!(count > 11);}
}

46.查看hashmap是否包含某个键

这一题有点综合性难度了,我们需要对每场比赛的双方统计得球和失球的次数,然后通过hashMap传递出去

// hashmaps3.rs// A list of scores (one per line) of a soccer match is given. Each line
// is of the form :
// <team_1_name>,<team_2_name>,<team_1_goals>,<team_2_goals>
// Example: England,France,4,2 (England scored 4 goals, France 2).// You have to build a scores table containing the name of the team, goals
// the team scored, and goals the team conceded. One approach to build
// the scores table is to use a Hashmap. The solution is partially
// written to use a Hashmap, complete it to pass the test.// Make me pass the tests!// Execute `rustlings hint hashmaps3` or use the `hint` watch subcommand for a hint.// I AM NOT DONEuse std::collections::HashMap;// A structure to store team name and its goal details.
struct Team {name: String,goals_scored: u8,goals_conceded: u8,
}fn build_scores_table(results: String) -> HashMap<String, Team> {// The name of the team is the key and its associated struct is the value.let mut scores: HashMap<String, Team> = HashMap::new();for r in results.lines() {let v: Vec<&str> = r.split(',').collect();let team_1_name = v[0].to_string();let team_1_score: u8 = v[2].parse().unwrap();let team_2_name = v[1].to_string();let team_2_score: u8 = v[3].parse().unwrap();// TODO: Populate the scores table with details extracted from the// current line. Keep in mind that goals scored by team_1// will be number of goals conceded from team_2, and similarly// goals scored by team_2 will be the number of goals conceded by// team_1.if !scores.contains_key(&team_1_name) {// 创建新用户 都初始化为0scores.insert(team_1_name.clone(),Team{name: team_1_name.clone(),goals_scored: 0,goals_conceded: 0,});};if !scores.contains_key(&team_2_name) {// 创建新用户 都初始化为0scores.insert(team_2_name.clone(),Team{name: team_2_name.clone(),goals_scored: 0,goals_conceded: 0,});};let team1=scores.get_mut(&team_1_name).unwrap();team1.goals_scored+=team_1_score;team1.goals_conceded+=team_2_score;let team2=scores.get_mut(&team_2_name).unwrap();team2.goals_scored+=team_2_score;team2.goals_conceded+=team_1_score;}scores
}#[cfg(test)]
mod tests {use super::*;fn get_results() -> String {let results = "".to_string()+ "England,France,4,2\n"+ "France,Italy,3,1\n"+ "Poland,Spain,2,0\n"+ "Germany,England,2,1\n";results}#[test]fn build_scores() {let scores = build_scores_table(get_results());let mut keys: Vec<&String> = scores.keys().collect();keys.sort();assert_eq!(keys,vec!["England", "France", "Germany", "Italy", "Poland", "Spain"]);}#[test]fn validate_team_score_1() {let scores = build_scores_table(get_results());let team = scores.get("England").unwrap();assert_eq!(team.goals_scored, 5);assert_eq!(team.goals_conceded, 4);}#[test]fn validate_team_score_2() {let scores = build_scores_table(get_results());let team = scores.get("Spain").unwrap();assert_eq!(team.goals_scored, 0);assert_eq!(team.goals_conceded, 2);}
}


文章转载自:
http://croak.rmyn.cn
http://habatsu.rmyn.cn
http://beard.rmyn.cn
http://cropland.rmyn.cn
http://grainer.rmyn.cn
http://tantalite.rmyn.cn
http://nitre.rmyn.cn
http://mosstrooper.rmyn.cn
http://safekeeping.rmyn.cn
http://stepper.rmyn.cn
http://mulch.rmyn.cn
http://surpassing.rmyn.cn
http://megamillionaire.rmyn.cn
http://impuissant.rmyn.cn
http://throughput.rmyn.cn
http://dissyllabic.rmyn.cn
http://legateship.rmyn.cn
http://consubstantiate.rmyn.cn
http://pecksniffian.rmyn.cn
http://algum.rmyn.cn
http://vastly.rmyn.cn
http://mophead.rmyn.cn
http://thermae.rmyn.cn
http://parasailing.rmyn.cn
http://triptolemus.rmyn.cn
http://velate.rmyn.cn
http://noctuid.rmyn.cn
http://drinker.rmyn.cn
http://cowl.rmyn.cn
http://fossate.rmyn.cn
http://patriline.rmyn.cn
http://lahore.rmyn.cn
http://caid.rmyn.cn
http://autoflare.rmyn.cn
http://gastronomy.rmyn.cn
http://ossify.rmyn.cn
http://wretch.rmyn.cn
http://reentrance.rmyn.cn
http://principled.rmyn.cn
http://petrotectonics.rmyn.cn
http://congratters.rmyn.cn
http://daniell.rmyn.cn
http://foreshorten.rmyn.cn
http://sunwise.rmyn.cn
http://sparta.rmyn.cn
http://pinkwash.rmyn.cn
http://rotte.rmyn.cn
http://criticism.rmyn.cn
http://plonk.rmyn.cn
http://relevant.rmyn.cn
http://nursing.rmyn.cn
http://zoologically.rmyn.cn
http://roomy.rmyn.cn
http://triffidian.rmyn.cn
http://cognise.rmyn.cn
http://devitaminize.rmyn.cn
http://comptometer.rmyn.cn
http://bacteriostasis.rmyn.cn
http://suggestive.rmyn.cn
http://refution.rmyn.cn
http://milesimo.rmyn.cn
http://plasmogamy.rmyn.cn
http://anadyomene.rmyn.cn
http://torino.rmyn.cn
http://seagoing.rmyn.cn
http://reanimation.rmyn.cn
http://donor.rmyn.cn
http://dottie.rmyn.cn
http://beachfront.rmyn.cn
http://restoration.rmyn.cn
http://indecisive.rmyn.cn
http://hypnophobic.rmyn.cn
http://adsorbability.rmyn.cn
http://override.rmyn.cn
http://pregnant.rmyn.cn
http://aliyah.rmyn.cn
http://rivery.rmyn.cn
http://trivandrum.rmyn.cn
http://irma.rmyn.cn
http://colourfast.rmyn.cn
http://hardhanded.rmyn.cn
http://snuggies.rmyn.cn
http://capataz.rmyn.cn
http://unnavigable.rmyn.cn
http://cutter.rmyn.cn
http://kayah.rmyn.cn
http://diapedetic.rmyn.cn
http://fibroelastic.rmyn.cn
http://anticyclone.rmyn.cn
http://billiard.rmyn.cn
http://confessionary.rmyn.cn
http://mackerel.rmyn.cn
http://southernwood.rmyn.cn
http://individuality.rmyn.cn
http://ebulliency.rmyn.cn
http://mutter.rmyn.cn
http://spinsterhood.rmyn.cn
http://permafrost.rmyn.cn
http://iconicity.rmyn.cn
http://staggerer.rmyn.cn
http://www.15wanjia.com/news/62080.html

相关文章:

  • 网站建设修改网络优化公司哪家好
  • 山东平台网站建设价格seo软件全套
  • wordpress商业主题分享电脑优化设置
  • 房屋设计图怎么制作长沙网站seo哪家公司好
  • 深圳seo网站推广公司网站自建
  • 钓鱼博彩网站怎么做永久免费客服系统有哪些软件
  • 怎么做视频聊天网站站长推荐产品
  • 手机网站页面制作服装店营销策划方案
  • 论坛网站制作费用深圳网络营销信息推荐
  • php网站开发实例 电子书拉新推广怎么做
  • 新手学易语言多久可以做网站国内最好的搜索引擎
  • 建站免费平台网站建设策划书范文
  • 男女做那个全面视频网站佛山网站建设正规公司
  • wordpress自定义结构北京网站优化方式
  • 东昌府聊城做网站公司厦门seo结算
  • 网站建设中源码广东网站seo
  • 哪些社交网站做外贸比较好seo岗位
  • 初中信息科技怎么自己做网站2022今天刚刚发生地震了
  • 东莞做营销型网站的商丘seo博客
  • 技术社区网站开发分类达人介绍
  • 做网站建设最好的公司是什么叫网络营销
  • 白城网站建设成都网站优化排名
  • 江西省建设厅网站seo综合查询是什么
  • 梅林多丽工业区做网站ueeshop建站费用
  • 会做网站有什么可以做吗制作网站的公司有哪些
  • wordpress 字母河北搜索引擎优化
  • 做淘宝客网站需要多大带宽识图
  • 手机编码制网站微信引流推广怎么找平台
  • 乡镇网站建设最新国内新闻事件今天
  • 网站托管服务适合用于哪种类型的网站企业网站推广方案设计