text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let digest = digest(&SHA256, &message.as_bytes()); HEXLOWER.encode(digest.as_ref()) } /* Validates the pattern given by the user Only valid if uses 1 to 5 hexadecimal characters */ fn pattern_is_valid(pattern: &String) -> bool { use regex::Regex; let regex...
code_fim
hard
{ "lang": "rust", "repo": "AmbryN/blockchain-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_previous(&self) -> String { let previous = self.previous.clone(); previous } pub fn set_previous(&mut self, previous: String) { self.previous = previous; } /* Mines a block until the hash starts with the defined pattern (max. 5 characters) a...
code_fim
hard
{ "lang": "rust", "repo": "AmbryN/blockchain-wasm", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AmbryN/blockchain-wasm path: /src/lib.rs mod utils; extern crate data_encoding; extern crate regex; extern crate ring; use data_encoding::HEXLOWER; use ring::digest::{digest, SHA256}; use utils::set_panic_hook; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_...
code_fim
hard
{ "lang": "rust", "repo": "AmbryN/blockchain-wasm", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amol9/ttt-frequency-counter path: /backend/rocket/src/main.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; extern crate reqwest; extern crate futures; <|fim_suffix|>fn main() { count::main(); }<|fim_middle|>#[allow(dead_code, unused_attributes, unused_must_...
code_fim
medium
{ "lang": "rust", "repo": "amol9/ttt-frequency-counter", "path": "/backend/rocket/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { count::main(); }<|fim_prefix|>// repo: amol9/ttt-frequency-counter path: /backend/rocket/src/main.rs #![feature(proc_macro_hygiene, decl_macro)] <|fim_middle|>#[macro_use] extern crate rocket; extern crate reqwest; extern crate futures; #[allow(dead_code, unused_attributes, unused_must_...
code_fim
medium
{ "lang": "rust", "repo": "amol9/ttt-frequency-counter", "path": "/backend/rocket/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code, unused_attributes, unused_must_use, unused_variables)] mod server; mod count; fn main() { count::main(); }<|fim_prefix|>// repo: amol9/ttt-frequency-counter path: /backend/rocket/src/main.rs #![feature(proc_macro_hygiene, decl_macro)] <|fim_middle|>#[macro_use] extern crate rocke...
code_fim
medium
{ "lang": "rust", "repo": "amol9/ttt-frequency-counter", "path": "/backend/rocket/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suyanlongfamily/rust_study path: /Study/tulp.rs use std::mem; //计算内存的包。 fn main() { //元组类型是自己组合的,通过() type Elment = (i32, String); //定义别名,通过type关键字。 let e: Elment = (12, "12312".to_string()); //转化类型 print<|fim_suffix|>数组有成员函数len(),看来和C 语言室友区别的。在堆中分配。 println!("array size:{}",...
code_fim
hard
{ "lang": "rust", "repo": "suyanlongfamily/rust_study", "path": "/Study/tulp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>数组有成员函数len(),看来和C 语言室友区别的。在堆中分配。 println!("array size:{}", mem::size_of_val(&xs));//5 * 4 = 20 println!("array size:{}", mem::size_of_val(&ys));//500 * 4 = 2000 }<|fim_prefix|>// repo: suyanlongfamily/rust_study path: /Study/tulp.rs use std::mem; //计算内存的包。 fn main() { //元组类型是自己组合的,通过() ...
code_fim
hard
{ "lang": "rust", "repo": "suyanlongfamily/rust_study", "path": "/Study/tulp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>sel3) module"] pub type SEL3 = crate::Reg<u16, _SEL3>; #[allow(missing_docs)] #[doc(hidden)] pub struct _SEL3; #[doc = "`read()` method returns [sel3::R](sel3::R) reader structure"] impl crate::Readable for SEL3 {} #[doc = "`write(|w| ..)` method takes [sel3::W](sel3::W) writer structure"] impl crate::Wri...
code_fim
hard
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-xbarb2/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-xbarb2/src/lib.rs #![deny(warnings)] #![allow(non_camel_case_types)] #![allow(clippy::all)] #![no_std] mod generic; pub use generic::*; #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Crossbar B Select Regis...
code_fim
hard
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-xbarb2/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caitlingao/leetcode_rust path: /src/cd0496_next_greater_element_i/mod.rs //! Next Greater Element I [leetcode: next_greater_element_i](https://leetcode.com/problems/next-greater-element-i/) //! //! You are given two arrays **(without duplicates)** `nums1` and `nums2` where `nums1`’s elements are...
code_fim
hard
{ "lang": "rust", "repo": "caitlingao/leetcode_rust", "path": "/src/cd0496_next_greater_element_i/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> nums2.iter().enumerate() { /// nums_map.insert(num, i); /// } /// /// for (i, num) in nums1.iter().enumerate() { /// for j in *nums_map.get(num).unwrap()..nums2.len() { /// if nums2[j] > *num { /// stack[i] = nums2[j]; /// ...
code_fim
hard
{ "lang": "rust", "repo": "caitlingao/leetcode_rust", "path": "/src/cd0496_next_greater_element_i/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_number(&mut self, n: u64) { self.number = n; } pub fn set_nodes(&mut self, nodes: Vec<Address>) { self.nodes = nodes } pub fn protobuf(&self) -> ProtoRichStatus { let mut ps = ProtoRichStatus::new(); ps.set_height(self.number()); ps....
code_fim
hard
{ "lang": "rust", "repo": "citahub/cita", "path": "/cita-chain/core/src/libchain/rich_status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: citahub/cita path: /cita-chain/core/src/libchain/rich_status.rs // Copyright Rivtower Technologies LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http:...
code_fim
hard
{ "lang": "rust", "repo": "citahub/cita", "path": "/cita-chain/core/src/libchain/rich_status.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_nodes(&mut self, nodes: Vec<Address>) { self.nodes = nodes } pub fn protobuf(&self) -> ProtoRichStatus { let mut ps = ProtoRichStatus::new(); ps.set_height(self.number()); ps.set_hash(self.hash().to_vec()); ps.set_nodes( self.node...
code_fim
hard
{ "lang": "rust", "repo": "citahub/cita", "path": "/cita-chain/core/src/libchain/rich_status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> _ => { println!("displaying loss data"); let mut data_file = BufReader::new(File::open("multiply_data").expect("failed to open file")); let (x, y) = read_gnuplot(&mut data_file); let mut fg = gnuplot::Figure::new(); fg.axes2d().lines(&x, &y, &[]); fg.show().expect("could not show g...
code_fim
hard
{ "lang": "rust", "repo": "djugei/dumbnet", "path": "/examples/multiplication.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djugei/dumbnet path: /examples/multiplication.rs use generic_array::{typenum, GenericArray}; use itertools::Itertools; use std::{ fs::File, io::{BufRead, BufReader, BufWriter, Write}, }; use bincode; use gnuplot; use dumbnet::{ activation::Sigmoid, layers::{InnerLayer, Layer, OutputLayer}...
code_fim
hard
{ "lang": "rust", "repo": "djugei/dumbnet", "path": "/examples/multiplication.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ufo-org/newYork path: /src/lib.rs #![feature( ptr_internals, once_cell, slice_ptr_get, mutex_unlock, thread_id_value, int_roundings, negative_impls, map_try_insert, option_result_unwrap_unchecked )] <|fim_suffix|>pub use ufo_objects::*; mod c_interface; pub...
code_fim
medium
{ "lang": "rust", "repo": "ufo-org/newYork", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use c_interface::core::*; pub use c_interface::object::*;<|fim_prefix|>// repo: ufo-org/newYork path: /src/lib.rs #![feature( ptr_internals, once_cell, slice_ptr_get, mutex_unlock, thread_id_value, int_roundings, negative_impls, map_try_insert, option_result_unwrap...
code_fim
easy
{ "lang": "rust", "repo": "ufo-org/newYork", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use ufo_objects::*; mod c_interface; pub use c_interface::core::*; pub use c_interface::object::*;<|fim_prefix|>// repo: ufo-org/newYork path: /src/lib.rs #![feature( ptr_internals, once_cell, slice_ptr_get, mutex_unlock, thread_id_value, int_roundings, negative_impls, ...
code_fim
medium
{ "lang": "rust", "repo": "ufo-org/newYork", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", point); } /// The following test function is necessary for the header generation. #[::safer_ffi::cfg_headers] #[test] fn generate_headers() -> ::std::io::Result<()> { ::safer_ffi::headers::builder() .to_file("rust_points.h")? .generate() }<|fim_prefix|>// repo: ge...
code_fim
hard
{ "lang": "rust", "repo": "getditto/safer_ffi", "path": "/examples/point/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: getditto/safer_ffi path: /examples/point/src/lib.rs use ::safer_ffi::prelude::*; /// A `struct` usable from both Rust and C #[derive_ReprC] #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct Point { x: f64, y: f64, } /* Export a Rust function to the C world. */ /// Returns the middle ...
code_fim
medium
{ "lang": "rust", "repo": "getditto/safer_ffi", "path": "/examples/point/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: earn-me-some-money/emtm-db path: /src/db_models/trade.rs use crate::schema::*; #[derive(Insertable, Queryable, Debug, Clone, AsCh<|fim_suffix|>item_info: String, pub item_condition: i8, pub address: String, }<|fim_middle|>angeset, Identifiable)] #[primary_key(mid)] #[table_name = "emtm_...
code_fim
medium
{ "lang": "rust", "repo": "earn-me-some-money/emtm-db", "path": "/src/db_models/trade.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub struct Trade { pub mid: i32, pub item_type: String, pub item_info: String, pub item_condition: i8, pub address: String, }<|fim_prefix|>// repo: earn-me-some-money/emtm-db path: /src/db_models/trade.rs use crate::schema::*; #[derive(Insertable, Queryable, Debug, Clone, AsCh<|fim_...
code_fim
medium
{ "lang": "rust", "repo": "earn-me-some-money/emtm-db", "path": "/src/db_models/trade.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let names = ["Graydon", "Brian", "Niko"]; println!("The second name is: {}", names[1]); let v = vec![1, 2, 3]; // x: Vec<i32> let mut nums = vec![1, 2, 3]; nums.push(4); println!("The length of nums is now {}", nums.len()); let v2 = [0, 1, 2, 3, 4]; let middle = &v2[1.....
code_fim
hard
{ "lang": "rust", "repo": "idreesdb/Tutorials", "path": "/rust/rustguide/hello_world/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> j = 5; loop { j += j - 3; println!("{}", j); if j % 5 == 0 { break; } } for x in 0u32..10 { if x % 2 == 0 { continue; } println!("{}", x); } let mut s = "Hello".to_string(); println!("{}", s); s.push_str(", world."); println!("{...
code_fim
hard
{ "lang": "rust", "repo": "idreesdb/Tutorials", "path": "/rust/rustguide/hello_world/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: idreesdb/Tutorials path: /rust/rustguide/hello_world/src/main.rs use std::cmp::Ordering; use std::io; use StringResult::StringOk; use StringResult::ErrorReason; enum StringResult { StringOk(String), ErrorReason(String), } struct Point { x: i32, y: i32, } #[allow(dead_code)] st...
code_fim
hard
{ "lang": "rust", "repo": "idreesdb/Tutorials", "path": "/rust/rustguide/hello_world/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abiriadev/smart-pointer path: /src/cons_list/list.rs #[derive(Debug)] enum List { // Cons(i32, List), Cons(i32, Box<List>), Nil, } <|fim_suffix|> println!("{:?}", list); }<|fim_middle|>pub fn list_main() { let list = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))))...
code_fim
medium
{ "lang": "rust", "repo": "abiriadev/smart-pointer", "path": "/src/cons_list/list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", list); }<|fim_prefix|>// repo: abiriadev/smart-pointer path: /src/cons_list/list.rs #[derive(Debug)] enum List { // Cons(i32, List), Cons(i32, Box<List>), Nil, } <|fim_middle|>pub fn list_main() { let list = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))))...
code_fim
medium
{ "lang": "rust", "repo": "abiriadev/smart-pointer", "path": "/src/cons_list/list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hannessalin/publications path: /project-euler-rust/problem001.rs use std::env; fn main() { <|fim_suffix|> let mut sum:i32 = 0; for n in 1..number { if (n % 3 == 0) | (n % 5 == 0) { sum = sum + n; } } println!("Total: {}",sum); }<|fim_middle|> let args: Vec<String> = env::args().coll...
code_fim
medium
{ "lang": "rust", "repo": "hannessalin/publications", "path": "/project-euler-rust/problem001.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum:i32 = 0; for n in 1..number { if (n % 3 == 0) | (n % 5 == 0) { sum = sum + n; } } println!("Total: {}",sum); }<|fim_prefix|>// repo: hannessalin/publications path: /project-euler-rust/problem001.rs use std::env; fn main() { <|fim_middle|> let args: Vec<String> = env::args().coll...
code_fim
medium
{ "lang": "rust", "repo": "hannessalin/publications", "path": "/project-euler-rust/problem001.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn serialize_structure_crate_input_update_intent_input( object: &mut aws_smithy_json::serialize::JsonObjectWriter, input: &crate::input::UpdateIntentInput, ) -> Result<(), aws_smithy_http::operation::SerializationError> { if let Some(var_225) = &input.description { object.key("desc...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/lexmodelsv2/src/json_ser.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/lexmodelsv2/src/json_ser.rs intent_sort_by( object: &mut aws_smithy_json::serialize::JsonObjectWriter, input: &crate::model::BuiltInIntentSortBy, ) -> Result<(), aws_smithy_http::operation::SerializationError> { if let Some(var_356) = &input.attribute...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/lexmodelsv2/src/json_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/lexmodelsv2/src/json_ser.rs ct.key("sortBy").start_object(); crate::json_ser::serialize_structure_crate_model_bot_locale_sort_by( &mut object_128, var_127, )?; object_128.finish(); } Ok(()) } pub fn seriali...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/lexmodelsv2/src/json_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alexr1239/learning-pathways path: /zomes/courses/code/src/lib.rs #![feature(proc_macro_hygiene)] extern crate hdk; extern crate hdk_proc_macros; extern crate serde; extern crate serde_derive; extern crate serde_json; extern crate holochain_json_derive; use hdk::{ entry_definition::Validatin...
code_fim
hard
{ "lang": "rust", "repo": "Alexr1239/learning-pathways", "path": "/zomes/courses/code/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[zome] mod my_zome { #[init] fn init() { Ok(()) } #[validate_agent] pub fn validate_agent(validation_data: EntryValidationData<AgentId>) { Ok(()) } #[entry_def] fn course_definition() -> ValidatingEntryType { course::entry_definition() } ...
code_fim
hard
{ "lang": "rust", "repo": "Alexr1239/learning-pathways", "path": "/zomes/courses/code/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Homework: add the get_course and delete_course endpoints #[zome_fn("hc_public")] fn get_course(course_address: Address) -> ZomeApiResult<Option<Entry>> { course::get_course(course_address) } #[zome_fn("hc_public")] fn delete_course(course_address: Address) -> ZomeApiRes...
code_fim
medium
{ "lang": "rust", "repo": "Alexr1239/learning-pathways", "path": "/zomes/courses/code/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match find_answer_part2(&numbers) { Some(n) => println!("{}", n), None => println!("Input doesn't contain solution for part 2"), } }<|fim_prefix|>// repo: cor/advent-of-code path: /2020/01/src/main.rs use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; #...
code_fim
hard
{ "lang": "rust", "repo": "cor/advent-of-code", "path": "/2020/01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn find_answer_part2(numbers: &[i64]) -> Option<i64> { for (i, j, k) in iproduct!(numbers, numbers, numbers) { if i + j + k == 2020 { return Some(i * j); } } None } fn main() { let file = File::open("./input/01.txt").expect("Failed to open file"); let numbe...
code_fim
medium
{ "lang": "rust", "repo": "cor/advent-of-code", "path": "/2020/01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cor/advent-of-code path: /2020/01/src/main.rs use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; #[macro_use] extern crate itertools; fn read_numbers<R: Read>(io: R) -> Result<Vec<i64>, Error> { <|fim_suffix|> match find_answer(&numbers) { Some(n) => print...
code_fim
hard
{ "lang": "rust", "repo": "cor/advent-of-code", "path": "/2020/01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcmendes/learnify path: /text2mp3/src/main.rs use base64; use std::fs; use std::io::prelude::*; fn main() { let text_in_base64 = "//OExAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
code_fim
hard
{ "lang": "rust", "repo": "rcmendes/learnify", "path": "/text2mp3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Nk66P//OExMwmChKYANIemNWD9HgbbiRm58I0LQWxYIIZiEoWhxnIe0Hu+QTgrxPZWFklMoDSGdGeJgoEANiubDgGoTpPnysbFAmHYnzM3M0DB2IukiTBqxggVEEE5upBN2TYwNF0Ej1dNmoutJSCmQQQZSbshTpGB51U9dnuu1t2am6CFCowQpvq1vdmWyq01LW2pkFn1C556PTvoncLgAkNhqPJ1/////62Ugt0/UirdbuVIoGyZSQQNXOlIojgLhKj//OExOYv8/KgAIvg3QYygoA3hhR+HAHALYJMJoIGUwpxg...
code_fim
hard
{ "lang": "rust", "repo": "rcmendes/learnify", "path": "/text2mp3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { put_str("Hello World\0".as_ptr()).unwrap() }; }<|fim_prefix|>// repo: CoZZmOnAvT/42-Piscine-C-In-Rust path: /put_str/src/main.rs unsafe fn put_str(str: *const u8) -> Result<isize, String> { if str == std::ptr::null() { Err("Nullptr was sent to function".to_string()) } else { ...
code_fim
easy
{ "lang": "rust", "repo": "CoZZmOnAvT/42-Piscine-C-In-Rust", "path": "/put_str/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CoZZmOnAvT/42-Piscine-C-In-Rust path: /put_str/src/main.rs unsafe fn put_str(str: *const u8) -> Result<isize, String> { if str == std::ptr::null() { Err("Nullptr was sent to function".to_string()) } else { let mut i: isize = 0; while *str.offset(i) != 0 as u8 { ...
code_fim
easy
{ "lang": "rust", "repo": "CoZZmOnAvT/42-Piscine-C-In-Rust", "path": "/put_str/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linuxaged/learnRust path: /closure.rs #![feature(core, unboxed_closures)] struct Struct<F> { f: F, } // `F` is the type of the unboxed closure // Is an unboxed closure because `F` implements the `FnOnce` trait impl<F> Struct<F> where F: FnOnce() { fn new(f: F) -> Struct<F> { St...
code_fim
easy
{ "lang": "rust", "repo": "linuxaged/learnRust", "path": "/closure.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn call(self) { self.f.call_once(()); } } fn main() { Struct::new(|| println!("Hello")).call(); }<|fim_prefix|>// repo: linuxaged/learnRust path: /closure.rs #![feature(core, unboxed_closures)] struct Struct<F> { f: F, } <|fim_middle|>// `F` is the type of the unboxed closure /...
code_fim
hard
{ "lang": "rust", "repo": "linuxaged/learnRust", "path": "/closure.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sisshiki1969/cilk path: /src/ir/licm.rs use crate::{ analysis::{ dom_tree::DominatorTreeConstructor, loops::{Loop, Loops, LoopsConstructor}, }, ir::{ basic_block::{BasicBlock, BasicBlockId}, builder::{Builder, FunctionEntity}, function::Functio...
code_fim
hard
{ "lang": "rust", "repo": "sisshiki1969/cilk", "path": "/src/ir/licm.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (id, loop_) in &loops.arena { let mut worklist = VecDeque::new(); for &bb_id in &loop_.set { let bb = &self.func.basic_blocks.arena[bb_id]; for inst_id in bb.iseq.borrow().iter().map(|v| v.as_instruction().id) { workl...
code_fim
hard
{ "lang": "rust", "repo": "sisshiki1969/cilk", "path": "/src/ir/licm.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !matches.is_present("yes") { confirm!("Delete the workspace '{}'", name); } Workspace::delete(name); println!("Deleted workspace '{}'", name); } ("list", Some(_)) => { let all = Workspace::all(); i...
code_fim
hard
{ "lang": "rust", "repo": "matthias-t/workspace", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matthias-t/workspace path: /src/main.rs #[macro_use] mod macros; mod app; mod exit; mod shell; mod tilde; mod workspace; use clap::ArgMatches; use colored::Colorize; use failure::Fail; use std::env; use std::fs; use std::io::Write; use std::path; use std::process; use crate::exit::Exit; use c...
code_fim
hard
{ "lang": "rust", "repo": "matthias-t/workspace", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fuzz_target!(|data| { let mut hasher = md4::Md4::new(); hasher.input(data); hasher.result(); });<|fim_prefix|>// repo: notriddle/targets path: /crypto-hashes/md4.rs #![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate md4; <|fim_middle|>use md4::Digest;
code_fim
easy
{ "lang": "rust", "repo": "notriddle/targets", "path": "/crypto-hashes/md4.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: notriddle/targets path: /crypto-hashes/md4.rs #![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate md4; <|fim_suffix|>fuzz_target!(|data| { let mut hasher = md4::Md4::new(); hasher.input(data); hasher.result(); });<|fim_middle|>use md4::Digest;
code_fim
easy
{ "lang": "rust", "repo": "notriddle/targets", "path": "/crypto-hashes/md4.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> if pieces.next() != Some("rustc 1") { return None; } otry!(pieces.next()).parse().ok() }<|fim_prefix|>// repo: delphix/ptools path: /vendor/libc/build.rs use std::env; use std::process::Command; use std::str; fn main() { /* * If `core::ffi::c_void` exists, libc can just re-...
code_fim
hard
{ "lang": "rust", "repo": "delphix/ptools", "path": "/vendor/libc/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: delphix/ptools path: /vendor/libc/build.rs use std::env; use std::process::Command; use std::str; fn main() { /* * If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it * must define an incompatible type to retain backwards-compatibility. */ if rustc_mi...
code_fim
hard
{ "lang": "rust", "repo": "delphix/ptools", "path": "/vendor/libc/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn poll_and_convert_response<T, F>( future: &mut F, ) -> Poll<tower_grpc::Response<T>, tower_grpc::Status> where F: Future<Error = core_error::Error>, F::Item: IntoProtobuf<T>, { match future.poll() { Ok(Async::NotReady) => Ok(Async::NotReady), Ok(Async::Ready(res)) => { ...
code_fim
hard
{ "lang": "rust", "repo": "Emurgo/chain-libs", "path": "/network-grpc/src/service/response_future.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn poll(&mut self) -> Poll<Self::Item, tower_grpc::Status> { if let ResponseFuture::Pending(f) = self { let res = poll_and_convert_response(f); if let Ok(Async::NotReady) = res { return Ok(Async::NotReady); } *self = ResponseFutur...
code_fim
hard
{ "lang": "rust", "repo": "Emurgo/chain-libs", "path": "/network-grpc/src/service/response_future.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emurgo/chain-libs path: /network-grpc/src/service/response_future.rs use crate::convert::{error_into_grpc, IntoProtobuf}; use network_core::error as core_error; use futures::prelude::*; use tower_grpc::{self, Code, Status}; use std::{marker::PhantomData, mem}; #[must_use = "futures do nothin...
code_fim
hard
{ "lang": "rust", "repo": "Emurgo/chain-libs", "path": "/network-grpc/src/service/response_future.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TaKO8Ki/wadachi path: /wadachi/src/filtering.rs use crate::event::{self, Event}; use regex::Regex; use scraper::{Html, Selector}; use std::error::Error; const PUSH_EVENT: &str = r"^Created \d{1,} commits in \d{1,} repositor(y|ies)$"; const PULL_REQUEST_REVIEW_EVENT: &str = r"^Reviewed \d{1,...
code_fim
hard
{ "lang": "rust", "repo": "TaKO8Ki/wadachi", "path": "/wadachi/src/filtering.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[async_std::test] async fn it_returns_error_when_day_is_less_than_1() -> Result<(), Box<dyn std::error::Error>> { let result1 = Filtering { user: "foo".to_string(), from: Date { year: 2019, month: 1, day: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "TaKO8Ki/wadachi", "path": "/wadachi/src/filtering.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn event_type(name: &str, event_type: &str) -> bool { Regex::new(event_type).unwrap().is_match(name) } #[cfg(test)] mod tests { use crate::{Date, Filtering}; #[async_std::test] async fn it_returns_error_when_from_month_is_less_than_1( ) -> Result<(), Box<dyn std::error::Error>> { ...
code_fim
hard
{ "lang": "rust", "repo": "TaKO8Ki/wadachi", "path": "/wadachi/src/filtering.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Node { pub fn new(value: &str, next: Option<NodeRef>) -> NodeRef { NodeRef::from_node(Node { value: String::from(value), next }) } pub fn next(&self) -> Option<NodeRef> { match &self.next { Some(node) => Some(node.refer()), ...
code_fim
hard
{ "lang": "rust", "repo": "nicolasjhampton/cs-data-structures-algorithms-in-rust", "path": "/src/lists/nodes/linked_list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicolasjhampton/cs-data-structures-algorithms-in-rust path: /src/lists/nodes/linked_list.rs use std::{ rc::Rc, cell::RefCell }; use super::{ RefExt, CreateRefExt }; pub type NodeRef = Rc<RefCell<Node>>; impl CreateRefExt for NodeRef { type Node = Node; type Reference = NodeRef; f...
code_fim
hard
{ "lang": "rust", "repo": "nicolasjhampton/cs-data-structures-algorithms-in-rust", "path": "/src/lists/nodes/linked_list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let node = Node::new("tonia", None); assert_eq!("tonia", node.value()); } #[test] fn value_returns_string() { let node = Node::new("tonia", None); assert_eq!("tonia".to_string(), node.value()); } #[test] fn next_gives_ref() { let mut node =...
code_fim
hard
{ "lang": "rust", "repo": "nicolasjhampton/cs-data-structures-algorithms-in-rust", "path": "/src/lists/nodes/linked_list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/tests/collections.rs prelude!(); #[test] fn test_hash_map_tile() { let _: () = rune! { pub fn main() { use std::collections::HashMap; enum Tile { Wall, } let m = HashMap::new(); <|...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/tests/collections.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> m.insert((0, 1), Tile::Wall); m[(0, 3)] = 5; assert_eq!(m.get((0, 1)), Some(Tile::Wall)); assert_eq!(m.get((0, 2)), None); assert_eq!(m[(0, 3)], 5); } }; } #[test] fn test_hash_set_tuple() { let _: () = rune! { pub fn ma...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/tests/collections.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "pkcs5")] pub(crate) mod encrypted_private_key_info; pub use crate::{ error::{Error, Result}, private_key_info::PrivateKeyInfo, traits::DecodePrivateKey, version::Version, }; pub use der::{self, asn1::ObjectIdentifier}; pub use spki::{self, AlgorithmIdentifier, DecodePubli...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/pkcs8-0.8.0/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/pkcs8-0.8.0/src/lib.rs #![doc = include_str!("../README.md")] //! ## About this crate //! This library provides generalized PKCS#8 support designed to work with a //! number of different algorithms. It supports `no_std` platforms including ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/pkcs8-0.8.0/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Stargateur/radixal path: /src/digits_iterator.rs use crate::IntoDigits; #[derive(Debug, PartialEq, Eq)] pub enum RadixError { Radix0, Radix1, } /// An iterator over the digits of a number. /// /// For a given radix, iterates over the digits in big endian order, i.e. from most significa...
code_fim
hard
{ "lang": "rust", "repo": "Stargateur/radixal", "path": "/src/digits_iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut digits = DigitsIterator::new(123_u32, 10).unwrap(); assert_eq!(digits.next_back(), Some(3)); assert_eq!(digits.next_back(), Some(2)); assert_eq!(digits.next_back(), Some(1)); assert_eq!(digits.next_back(), None); } #[test] fn test_exact_power()...
code_fim
hard
{ "lang": "rust", "repo": "Stargateur/radixal", "path": "/src/digits_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tonpublic/TON-SDK path: /ton_sdk/src/types.rs /* * Copyright 2018-2019 TON DEV SOLUTIONS LTD. * * Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at: https://ton.dev/license...
code_fim
hard
{ "lang": "rust", "repo": "tonpublic/TON-SDK", "path": "/ton_sdk/src/types.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for StringId { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f,"{}", self.0) } } impl StringId { pub fn to_base64(&self) -> SdkResult<String> { let bytes = self.to_bytes()?; Ok(base64::encode(&bytes)) } pub fn to_bytes(&self) ...
code_fim
hard
{ "lang": "rust", "repo": "tonpublic/TON-SDK", "path": "/ton_sdk/src/types.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns true if none of the `Token`s in this set have been dropped. /// /// # Examples /// /// ``` /// # use dropcheck::DropCheck; /// let set = DropCheck::new(); /// assert!(set.none_dropped()); // an empty set has no dropped tokens /// /// let t1 = set.token()...
code_fim
hard
{ "lang": "rust", "repo": "petertodd/dropcheck", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> f.debug_struct(&format!("DropState<{:p}>", self)) .field("count", &self.count) .finish() } } impl Drop for DropState { fn drop(&mut self) { match self.count.get_mut() { 1 => {}, 0 => panic!("token not dropped"), _ => pani...
code_fim
hard
{ "lang": "rust", "repo": "petertodd/dropcheck", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: petertodd/dropcheck path: /src/lib.rs //! Tooling to check the correctness of `Drop` implementations. //! //! Properly testing a container type like `Vec<T>` requires verifying that every value in the //! container is neither leaked, nor dropped multiple times. //! //! To detect leaks, this crat...
code_fim
hard
{ "lang": "rust", "repo": "petertodd/dropcheck", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct RenderedJabbering(Entity); pub struct RenderedJabberingRoot; pub fn rendered_jabbering_system( font: Res<Handle<Font>>, commands: &mut Commands, query: Query< ( Entity, &Jabbering, Option<&String>, Option<&RenderedJabbering>, ...
code_fim
hard
{ "lang": "rust", "repo": "payload/bevy-thing", "path": "/src/systems/jabber.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: payload/bevy-thing path: /src/systems/jabber.rs use bevy::prelude::*; use rand::Rng; const LINES_OF_GREAT_IMPORTANCE: [&'static str; 7] = [ "This isn't just about you. It's about what's best for all of us.", "What are you gonna do?", "Think about it. Is it really the right choice?",...
code_fim
hard
{ "lang": "rust", "repo": "payload/bevy-thing", "path": "/src/systems/jabber.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let root = root_query.iter().next(); if root.is_none() { return; } let root = root.unwrap(); for (entity, jabbering, name, rendered) in query.iter() { for line in jabbering.get_line() { let mut text_value = if let Some(name) = name { format!...
code_fim
hard
{ "lang": "rust", "repo": "payload/bevy-thing", "path": "/src/systems/jabber.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let contact = connections.contact.clone().unwrap(); let web3 = connections.web3.unwrap(); let mut grpc = connections.grpc.unwrap(); // check if the cosmos node is syncing, if so wait for it // we can't move any steps above this because they may fail on an incorrect // historic cha...
code_fim
hard
{ "lang": "rust", "repo": "puneetsingh166/cosmos-gravity-PRTesting", "path": "/orchestrator/gbt/src/relayer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // get the gravity contract address, if not provided let contract_address = if let Some(c) = args.gravity_contract_address { c } else { let params = get_gravity_params(&mut grpc).await.unwrap(); let c = params.bridge_ethereum_address.parse(); if c.is_err() { ...
code_fim
hard
{ "lang": "rust", "repo": "puneetsingh166/cosmos-gravity-PRTesting", "path": "/orchestrator/gbt/src/relayer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: puneetsingh166/cosmos-gravity-PRTesting path: /orchestrator/gbt/src/relayer.rs use crate::args::RelayerOpts; use crate::config::config_exists; use crate::config::load_keys; use cosmos_gravity::query::get_gravity_params; use gravity_utils::connection_prep::{ check_for_eth, create_rpc_connecti...
code_fim
hard
{ "lang": "rust", "repo": "puneetsingh166/cosmos-gravity-PRTesting", "path": "/orchestrator/gbt/src/relayer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let benchmark = ParameterizedBenchmark::new( "gaussian_mixture", move |bencher, &cluster_size| { let n_clusters = 4; let n_features = 3; let centroids = Array2::random_using((n_clusters, n_features), Uniform::new(-30., 30.), &mut rng)...
code_fim
medium
{ "lang": "rust", "repo": "bytesnake/linfa", "path": "/linfa-clustering/benches/gaussian_mixture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytesnake/linfa path: /linfa-clustering/benches/gaussian_mixture.rs use criterion::{ black_box, criterion_group, criterion_main, AxisScale, Criterion, ParameterizedBenchmark, PlotConfiguration, }; use linfa::traits::Fit; use linfa::Dataset; use linfa_clustering::{generate_blobs, Gaussian...
code_fim
medium
{ "lang": "rust", "repo": "bytesnake/linfa", "path": "/linfa-clustering/benches/gaussian_mixture.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = Isaac64Rng::seed_from_u64(40); let cluster_sizes = vec![10, 100, 1000, 10000]; let benchmark = ParameterizedBenchmark::new( "gaussian_mixture", move |bencher, &cluster_size| { let n_clusters = 4; let n_features = 3; let centroi...
code_fim
medium
{ "lang": "rust", "repo": "bytesnake/linfa", "path": "/linfa-clustering/benches/gaussian_mixture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: filkry/rusgam path: /src/entity.rs use crate::allocate::{SYSTEM_ALLOCATOR}; use crate::collections::{SStoragePool, SPoolHandle}; use crate::entitytypes::{EEntityType}; use crate::math::{Vec3}; use crate::utils::{STransform}; use crate::string_db::{SHashedStr, hash_str}; #[allow(dead_code)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "filkry/rusgam", "path": "/src/entity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_entity_debug_name(&mut self, entity: SEntityHandle, debug_name: &str) { self.entities.get_mut(entity).expect("invalid entity").debug_name = Some(hash_str(debug_name)); } pub fn get_entity_debug_name(&self, entity: SEntityHandle) -> &Option<SHashedStr> { &self.entiti...
code_fim
hard
{ "lang": "rust", "repo": "filkry/rusgam", "path": "/src/entity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ReduceMin { /// Creates new reduce mean operation. #[inline(always)] pub fn new<S: Into<String>, A: Into<Axes>>(input: S, axes: A, keepdims: bool) -> Self { ReduceMin { inner: builder::Node::new("ReduceMin") .input(input) .attribute("axe...
code_fim
medium
{ "lang": "rust", "repo": "crackcomm/onnx-helpers-rs", "path": "/src/nodes/ops/reduce_min.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crackcomm/onnx-helpers-rs path: /src/nodes/ops/reduce_min.rs //! Reduce mean operation. use onnx_pb::Axes; use crate::{builder, node_to_inner, nodes::Node}; <|fim_suffix|>impl ReduceMin { /// Creates new reduce mean operation. #[inline(always)] pub fn new<S: Into<String>, A: Into<...
code_fim
medium
{ "lang": "rust", "repo": "crackcomm/onnx-helpers-rs", "path": "/src/nodes/ops/reduce_min.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn compare(&self, other: &Pair) -> LispResult<Ordering> { let res1 = self.get_fst().compare(&other.get_fst())?; if res1 == Ordering::Equal { self.rst.borrow().compare(&other.rst.borrow()) } else { Ok(res1) } } pub fn is_equal(&self, ...
code_fim
hard
{ "lang": "rust", "repo": "l3kn/EulerLisp", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: l3kn/EulerLisp path: /src/lib.rs #![feature(try_trait)] #[macro_use] extern crate lisp_macros; #[macro_use] extern crate lazy_static; #[macro_use] mod macros; pub mod code_formatter; pub mod compiler; pub mod debugger; pub mod doc; pub mod parser; pub mod repl; pub mod symbol_table; pub mod ...
code_fim
hard
{ "lang": "rust", "repo": "l3kn/EulerLisp", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fa.partial_cmp(&fb).expect("Received a NaN") }) .expect("Population is empty") .curr_value .clone(); let best_fitness = self.fitness.calculate_for_maximization(&self.global_best); let local_fitness = self.fitness.calculate_fo...
code_fim
hard
{ "lang": "rust", "repo": "quebin31/pso", "path": "/src/pso.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quebin31/pso path: /src/pso.rs use crate::fitness::Fitness; use anyhow::Error; use ndarray::Array1; use ndarray_rand::rand_distr::Uniform; use ndarray_rand::RandomExt; use plotters::coord::Shift; use plotters::drawing::backend::DrawingBackend; use plotters::prelude::*; use rand::{thread_rng, Rng...
code_fim
hard
{ "lang": "rust", "repo": "quebin31/pso", "path": "/src/pso.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (i, particle) in &mut self.particles.iter_mut().enumerate() { particle.update_velocity(&self.global_best, &mut rng, &options); particle.update_value(); particle.update_best(&self.fitness); println!( "{}) x: {}, v: {}", ...
code_fim
hard
{ "lang": "rust", "repo": "quebin31/pso", "path": "/src/pso.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dnsl48/fraction path: /src/fraction/ops/add.rs use crate::fraction::{GenericFraction, Sign}; use crate::Integer; use std::ops::{Add, Sub}; impl<T, O> Add<O> for GenericFraction<T> where T: Clone + Integer, O: Into<GenericFraction<T>>, { type Output = Self; fn add(self, other: O...
code_fim
hard
{ "lang": "rust", "repo": "dnsl48/fraction", "path": "/src/fraction/ops/add.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match *self { GenericFraction::NaN => self.clone(), GenericFraction::Infinity(sign) => match *other { GenericFraction::NaN => other.clone(), GenericFraction::Rational(_, _) => self.clone(), GenericFraction::Infinity(osign) => ...
code_fim
hard
{ "lang": "rust", "repo": "dnsl48/fraction", "path": "/src/fraction/ops/add.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let other = other.into(); match *self { GenericFraction::NaN => self.clone(), GenericFraction::Infinity(sign) => match other { GenericFraction::NaN => other, GenericFraction::Rational(_, _) => self.clone(), GenericFra...
code_fim
hard
{ "lang": "rust", "repo": "dnsl48/fraction", "path": "/src/fraction/ops/add.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let recorder = Recorder::new(recorder_dir_path); recorder.prune_job_dirs() }<|fim_prefix|>// repo: uasi/vrec path: /src/cli.rs use std::io; use std::path::PathBuf; use crate::recorder::Recorder; pub fn gc() -> io::Result<()> { dotenv::dotenv().ok(); <|fim_middle|> let var_dir_path = do...
code_fim
medium
{ "lang": "rust", "repo": "uasi/vrec", "path": "/src/cli.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uasi/vrec path: /src/cli.rs use std::io; use std::path::PathBuf; use crate::recorder::Recorder; <|fim_suffix|> let var_dir_path = dotenv::var("VAR_DIR").unwrap_or_else(|_| "var".to_owned()); let recorder_dir_path = PathBuf::from(var_dir_path).join("jobs"); let recorder = Recorder::...
code_fim
medium
{ "lang": "rust", "repo": "uasi/vrec", "path": "/src/cli.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/ARC003/c/src/main.rs fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: usize = rd.get(); let _: usize = rd.get(); let a: Vec<Vec<char>> = (0..n).map(|_| rd.get_chars()).collect(); ...
code_fim
hard
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/ARC003/c/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn half_open_range(rng: impl std::ops::RangeBounds<usize>) -> std::ops::Range<usize> { use std::ops::Bound::{Excluded, Included, Unbounded}; let start = match rng.start_bound() { Included(&s) => s, Excluded(&s) => s + 1, Unbounded => 0, }; let end = match rng.end_bo...
code_fim
hard
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/ARC003/c/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: virtualritz/simdeez path: /src/libm/mod.rs //! libm in pure Rust //! //! This is pulled from https://github.com/rust-lang-nursery/libm //! Maintainers of that project have gone dark, and I had to fix some things //! so I just pulled it into simdeez. //! This is all just to support no_std //! #!...
code_fim
hard
{ "lang": "rust", "repo": "virtualritz/simdeez", "path": "/src/libm/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }