text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: amyyq2/cs196 path: /Rust/section-one/plato/src/lib/file.rs use std::fs; use users::{get_user_by_uid, get_current_uid}; use fs::Metadata; use std::os::unix::fs::MetadataExt; use chrono::{DateTime, Local}; use libc::{S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR};...
code_fim
hard
{ "lang": "rust", "repo": "amyyq2/cs196", "path": "/Rust/section-one/plato/src/lib/file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Setup let mut f = File::create("first.txt").unwrap(); f.write_all(b"Hello, world!").unwrap(); let file_path = PathBuf::from("first.txt"); let meta = file_path.metadata().unwrap(); let human_size = get_human_file_size(&meta); // Test ...
code_fim
hard
{ "lang": "rust", "repo": "amyyq2/cs196", "path": "/Rust/section-one/plato/src/lib/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>const TIMER_INTERVAL: usize = 25; // in ms pub const TIMER_INTERRUPT_VEC: u8 = 32; /// /// Enables Apic timer /// pub fn enable_timer() { unsafe { msr::wrmsr(msr::IA32_X2APIC_DIV_CONF, 3); msr::wrmsr(msr::IA32_X2APIC_LVT_TIMER, 1 << 17 | TIMER_INTERRUPT_VEC as u64); let calib_...
code_fim
hard
{ "lang": "rust", "repo": "liuzix/rustos", "path": "/src/devices/apic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liuzix/rustos path: /src/devices/apic.rs use x86::bits64::cpuid; use x86::shared::{msr, irq}; use x86::shared::io; use bit_field::BitField; use core::sync::atomic::*; pub static CPU_COUNT: AtomicUsize = ATOMIC_USIZE_INIT; pub fn mp_apic_init() -> u32 { CPU_COUNT.fetch_add(1, Ordering::Rela...
code_fim
hard
{ "lang": "rust", "repo": "liuzix/rustos", "path": "/src/devices/apic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xsoer/insighter path: /src/main.rs mod insight; use clap::{load_yaml, App}; use insight::rust::run; // use std::env; use std::path::Path; fn main() { <|fim_suffix|>fn options() -> String { let yaml = load_yaml!("cli.yml"); let matches = App::from(yaml).get_matches(); String::from(m...
code_fim
medium
{ "lang": "rust", "repo": "xsoer/insighter", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let yaml = load_yaml!("cli.yml"); let matches = App::from(yaml).get_matches(); String::from(matches.value_of("DIR").unwrap()) } // fn arg() { // let args: Vec<String> = env::args().collect(); // if args.len() < 2 { // println!("参数必须至少是2个!"); // return; // } // }<|fim_prefix|>// repo: xsoer/in...
code_fim
medium
{ "lang": "rust", "repo": "xsoer/insighter", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glyn/rustrest path: /src/bin/client.rs extern crate hyper; extern crate hyper_native_tls; use std::env; use std::io::Read; use hyper::Client; use hyper::client::response::Response; use hyper_native_tls::NativeTlsClient; use hyper::net::HttpsConnector; fn main() { let url = match env::args(...
code_fim
medium
{ "lang": "rust", "repo": "glyn/rustrest", "path": "/src/bin/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn read_to_string(mut r: Response) -> hyper::Result<String> { let mut s = String::new(); try!(r.read_to_string(&mut s)); Ok(s) }<|fim_prefix|>// repo: glyn/rustrest path: /src/bin/client.rs extern crate hyper; extern crate hyper_native_tls; use std::env; use std::io::Read; use hyper::Client;...
code_fim
hard
{ "lang": "rust", "repo": "glyn/rustrest", "path": "/src/bin/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(CommonJson { preamble: 0x55, sender: msg.get_sender_id().unwrap_or(0), msg_type: msg.get_message_type(), length: length as u8, payload: payload_buf, crc, }) } /// Provide Haskell style formatting. Output should be similar to: https://hackage.hask...
code_fim
hard
{ "lang": "rust", "repo": "arsenyvasilyev/libsbp", "path": "/rust/sbp/src/codec/json.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arsenyvasilyev/libsbp path: /rust/sbp/src/codec/json.rs use std::{borrow::Borrow, collections::HashMap}; use bytes::{Buf, BufMut, BytesMut}; use dencode::{Decoder, Encoder, FramedWrite}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::{ser::Formatter, Deserializer, Se...
code_fim
hard
{ "lang": "rust", "repo": "arsenyvasilyev/libsbp", "path": "/rust/sbp/src/codec/json.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ingod9true/qscode path: /src/tokio_sync/mod.rs mod oneshot; mod lock; pub mod io; use tokio::sync::Barrier; use std::sync::Arc; async fn xxx(){ <|fim_suffix|>// Will not resolve until all "after wait" messages have been printed let mut num_leaders = 0; for handle in handles { ...
code_fim
hard
{ "lang": "rust", "repo": "ingod9true/qscode", "path": "/src/tokio_sync/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// Will not resolve until all "after wait" messages have been printed let mut num_leaders = 0; for handle in handles { let wait_result = handle.await.unwrap(); if wait_result.is_leader() { num_leaders += 1; } } // is_leader 只有一个线程返回true,其他的为false assert...
code_fim
hard
{ "lang": "rust", "repo": "ingod9true/qscode", "path": "/src/tokio_sync/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: knpwrs/learning-rust path: /code/c18-03-patterns-syntax/src/main.rs fn main() { let x = 1; let y = Some(10); let c = 'c'; // Matching Literals match x { 1 => println!("One!"), 2 => println!("One!"), 3 => println!("One!"), 4 => println!("One!")...
code_fim
hard
{ "lang": "rust", "repo": "knpwrs/learning-rust", "path": "/code/c18-03-patterns-syntax/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { // Creating references let robot_name = Some(String::from("Bender")); match robot_name { Some(ref name) => println!("{}", name), None => (), }; let mut robot_name = Some(String::from("Bender")); match robot_name { S...
code_fim
hard
{ "lang": "rust", "repo": "knpwrs/learning-rust", "path": "/code/c18-03-patterns-syntax/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn delete_person(id: i32) -> Result<impl warp::Reply, warp::Rejection> { let res = person_client::delete_person(id) .await .expect("Could not delete person"); Ok(warp::reply::json(&res.message)) } pub async fn read_person_list() -> Result<impl warp::Reply, warp::Rejecti...
code_fim
hard
{ "lang": "rust", "repo": "Mutestock/mini-proj2", "path": "/bus/src/logic/person_handlers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn read_person_list() -> Result<impl warp::Reply, warp::Rejection> { let res = person_client::read_person_list() .await .expect("Could not read person list"); Ok(warp::reply::json(&Person::from_read_list_response( res.person_list, ))) } pub async fn read_per...
code_fim
hard
{ "lang": "rust", "repo": "Mutestock/mini-proj2", "path": "/bus/src/logic/person_handlers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mutestock/mini-proj2 path: /bus/src/logic/person_handlers.rs use crate::clients::grpc::person_client; use crate::entities::person::{NewPerson, Person}; pub async fn create_person(person: NewPerson) -> Result<impl warp::Reply, warp::Rejection> { let res = person_client::create_person(person)...
code_fim
hard
{ "lang": "rust", "repo": "Mutestock/mini-proj2", "path": "/bus/src/logic/person_handlers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn separator() -> &'static str { ", " } }<|fim_prefix|>// repo: RNAcentral/rnacentral-import-pipeline path: /utils/search-export/src/sequences/comma_space_sep.rs #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] pub struct CommaSpaceSeparator;<|fim_middle|> impl ...
code_fim
easy
{ "lang": "rust", "repo": "RNAcentral/rnacentral-import-pipeline", "path": "/utils/search-export/src/sequences/comma_space_sep.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|> impl Separator for CommaSeparator { #[inline] fn separator() -> &'static str { ", " } }<|fim_prefix|>// repo: RNAcentral/rnacentral-import-pipeline path: /utils/search-export/src/sequences/comma_space_sep.rs #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, <|fim_middle|>Hash, D...
code_fim
easy
{ "lang": "rust", "repo": "RNAcentral/rnacentral-import-pipeline", "path": "/utils/search-export/src/sequences/comma_space_sep.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RNAcentral/rnacentral-import-pipeline path: /utils/search-export/src/sequences/comma_space_sep.rs #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] pub struct CommaSpaceSeparator;<|fim_suffix|> fn separator() -> &'static str { ", " } }<|fim_middle|> impl ...
code_fim
easy
{ "lang": "rust", "repo": "RNAcentral/rnacentral-import-pipeline", "path": "/utils/search-export/src/sequences/comma_space_sep.rs", "mode": "psm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kixunil/ttt path: /cli/src/main.rs mod stats; mod group; use chrono::Local; fn process_stats(mut args: std::env::Args) -> Result<(), anyhow::Error> { use chrono::Datelike; let period0 = args.next().ok_or_else(|| anyhow::anyhow!("udefined period, known periods: today, yesterday, this {w...
code_fim
hard
{ "lang": "rust", "repo": "Kixunil/ttt", "path": "/cli/src/main.rs", "mode": "psm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> Result<(), anyhow::Error> { let mut args = std::env::args(); let _program = args.next().ok_or_else(|| anyhow::anyhow!("not even zeroth argument present"))?; let command = args.next().ok_or_else(|| anyhow::anyhow!("no command given, available commands: stats"))?; match &*comma...
code_fim
hard
{ "lang": "rust", "repo": "Kixunil/ttt", "path": "/cli/src/main.rs", "mode": "spm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_suffix|> /// Change the foreground color to bright black /// Change the background color to bright black BrightBlack bright_black on_bright_black, /// Change the foreground color to bright red /// Change the background color to bright red BrightRed bright_red on_bright_red, ...
code_fim
hard
{ "lang": "rust", "repo": "ric2b/Vivaldi-browser", "path": "/chromium/third_party/rust/owo_colors/v3/crate/src/combo.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn bg_fg_dyn_combo() { let test = "test".on_color(AnsiColors::Blue).color(AnsiColors::Red); assert_eq!(test.to_string(), "\x1b[31;44mtest\x1b[0m"); } #[test] fn fg_overide() { let test = "test".green().yellow().red().on_blue(); assert_eq!(test.t...
code_fim
hard
{ "lang": "rust", "repo": "ric2b/Vivaldi-browser", "path": "/chromium/third_party/rust/owo_colors/v3/crate/src/combo.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/owo_colors/v3/crate/src/combo.rs e color is constant, use either [`OwoColorize::bg`](OwoColorize::bg) or /// a color-specific method, such as [`OwoColorize::on_yellow`](OwoColorize::on_yellow), /// /// ```...
code_fim
hard
{ "lang": "rust", "repo": "ric2b/Vivaldi-browser", "path": "/chromium/third_party/rust/owo_colors/v3/crate/src/combo.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init_vertex() { implement_vertex!(Vertex, position, color); }<|fim_prefix|>// repo: yeliknewo/rs-dorp path: /src/graphics/vertex_color/vertex.rs #[derive(Debug, Copy, Clone)] pub struct Vertex { position: [f32; 3], color: [f32; 4], } <|fim_middle|>impl Vertex { pub fn new(position...
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/graphics/vertex_color/vertex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yeliknewo/rs-dorp path: /src/graphics/vertex_color/vertex.rs #[derive(Debug, Copy, Clone)] pub struct Vertex { position: [f32; 3], color: [f32; 4], } <|fim_suffix|> pub fn init_vertex() { implement_vertex!(Vertex, position, color); }<|fim_middle|>impl Vertex { pub fn new(positio...
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/rs-dorp", "path": "/src/graphics/vertex_color/vertex.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_royal_flush(_hand: &Vec<Card>) -> bool { (is_straight(_hand) && is_flush(_hand)) } fn check_hand(hand: &Vec<Card>, bet: i32) -> i32 { let mut win = -1; if is_royal_flush(hand) { win = bet * 50; println!("Royal flush! Win {}", win); } else if is_four_of_kind(hand) { ...
code_fim
hard
{ "lang": "rust", "repo": "mikkolundgren/ray-poker", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut bank = 20; while bank > 0 { println!("Bank: {}", bank); let mut deck = Deck::init(); let hand = deal_cards(&mut deck, 5); print_hand(&hand); println!("Input cards you want to keep."); let mut selection = String::new(); io::stdin().rea...
code_fim
hard
{ "lang": "rust", "repo": "mikkolundgren/ray-poker", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikkolundgren/ray-poker path: /src/main.rs use rand::{Rng, StdRng}; use std::io; #[derive(Clone, Debug)] struct Card { suit: u8, rank: u8, symbol: String, suit_symbol: String, } impl Card { fn init(rank: u8, suit: u8) -> Card { let symbol = match rank { ...
code_fim
hard
{ "lang": "rust", "repo": "mikkolundgren/ray-poker", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use index::{Index, IndexBuilder, MultiDocIndex, MultiDocIndexBuilder};<|fim_prefix|>// repo: mosmeh/suffine path: /src/lib.rs #[cfg(test)] #[macro_use] extern crate quickcheck_macros; <|fim_middle|>mod build; mod error; mod index; pub use error::Error; pub type Result<T> = std::result::Result<T, er...
code_fim
medium
{ "lang": "rust", "repo": "mosmeh/suffine", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mosmeh/suffine path: /src/lib.rs #[cfg(test)] #[macro_use] extern crate quickcheck_macros; <|fim_suffix|>pub use error::Error; pub type Result<T> = std::result::Result<T, error::Error>; pub use index::{Index, IndexBuilder, MultiDocIndex, MultiDocIndexBuilder};<|fim_middle|>mod build; mod error...
code_fim
easy
{ "lang": "rust", "repo": "mosmeh/suffine", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct InteractionCommand { pub permissions: Option<Permissions>, pub channel_id: Id<ChannelMarker>, pub data: Box<CommandData>, pub guild_id: Option<Id<GuildMarker>>, pub id: Id<InteractionMarker>, pub member: Option<PartialMember>, pub token: String, ...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/util/interaction.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/util/interaction.rs use eyre::{ContextCompat, Result}; use twilight_model::{ application::interaction::{ application_command::CommandData, message_component::MessageComponentInteractionData, modal::ModalInteractionData, }, channel::Me...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/util/interaction.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> self.member .as_ref() .and_then(|member| member.user.as_ref()) .or(self.user.as_ref()) .wrap_err("Missing both member and user") } } )* }; } impl_aut...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/util/interaction.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 07th-mod/python-patcher path: /install_loader/src/process_runner.rs use crate::windows_utilities; use std::error::Error; use std::ffi::OsStr; use std::os::windows::io::AsRawHandle; use std::path::Path; use std::process::{Child, Command}; use win32job::Job; //spawn a thread to monitor the stdout...
code_fim
hard
{ "lang": "rust", "repo": "07th-mod/python-patcher", "path": "/install_loader/src/process_runner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ProcessRunner { pub fn new<I, S>( full_executable_path: &Path, working_directory: &Path, arguments: I, ) -> Result<ProcessRunner, Box<dyn Error>> where I: IntoIterator<Item = S> + std::fmt::Debug, S: AsRef<OsStr>, { println!( "Starting {:?} in directory {:?} with arguments [{:?}]"...
code_fim
medium
{ "lang": "rust", "repo": "07th-mod/python-patcher", "path": "/install_loader/src/process_runner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielKeep/rust-scan path: /src/lib.rs tern crate scan_util; ``` Note that `scan_util` *must* be in the root module, and *must* not be renamed. This is due to a limitation of macros in Rust. ## Usage Several macros are provided for scanning text. In general, they are concerned with taking a...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-scan", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>There are several attributes you can set on individual patterns. They can be written in any order prior to the start of a pattern. #### `#[tokenizer="..."]` and `#[runtime_tok="..."]` These set the tokenisers used to turn string literals in the pattern *and* the input string into a sequence of tokens. ...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-scan", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>* `["pretty"]+ "please"` - matches a childish plea. * `"rgb (" [cs],{3} ")"` - matches a CSS `rgb` colour value, with comma-separated values. * `[ns:int](ws:&str)+` - matches a sequence of at least one number separated by arbitrary words, with both the numbers *and* words being captured. The `separator...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-scan", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let string = String::from("test"); if winner(String::from("test"), String::from("test2"), move |_a,_b| { println!("{}", string); // Doesn't require ownership on the string true }) { //println!("{}", string); // The line above will only compile if we removes the...
code_fim
hard
{ "lang": "rust", "repo": "oribenshir/learning_rust", "path": "/closures_playground/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oribenshir/learning_rust path: /closures_playground/src/main.rs fn winner<T, F> (a : T, b : T, bigger_fn : F) -> bool where F : FnOnce(T, T) -> bool { bigger_fn(a,b) } enum TypedIf { Then, Else } fn do_a() -> bool { // Complex operation which might fail true } fn do_ve...
code_fim
hard
{ "lang": "rust", "repo": "oribenshir/learning_rust", "path": "/closures_playground/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hassanin/rust-wordpress path: /src/config.rs // use std::collections::HashMap; // use std::env; use serde::{Deserialize, Serialize}; use std::fs; // Reads the config files pub fn read_config() -> Result<ConfigSettings, String> { let filename = "./config/main.json"; let contents = fs::re...
code_fim
medium
{ "lang": "rust", "repo": "hassanin/rust-wordpress", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub enum LogLevel { #[serde(rename = "debug")] Debug, #[serde(rename = "warn")] Warn, #[serde(rename = "info")] Info, #[serde(rename = "error")] Error, }<|fim_prefix|>// repo: hassanin/rust-wordpress path: /src/config.r...
code_fim
hard
{ "lang": "rust", "repo": "hassanin/rust-wordpress", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hmgibson23/rs-templates path: /src/lexer/mod.rs use std::char; use std::fs::File; use std::io::Read; /* The lexer that lexes */ #[derive(Clone, PartialEq)] pub enum Token { Expr(String), Missing } impl Token { pub fn stringify(self) -> String { match self { Tok...
code_fim
hard
{ "lang": "rust", "repo": "hmgibson23/rs-templates", "path": "/src/lexer/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // check if we're at the end yet if complete_token(last_char.clone()) { tokens.push(get_expr(last_char.clone())); tokenizing = 0; last_char = String::new() } continue; } if c == '{' { ...
code_fim
hard
{ "lang": "rust", "repo": "hmgibson23/rs-templates", "path": "/src/lexer/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl SceneNode { pub fn new() -> Node { ManuallyDrop::new(Pin::new(Box::new(SceneNode { position: glm::zero(), rotation: glm::zero(), scale: glm::vec3(1.0, 1.0, 1.0), reference_point: glm::zero(), current_transformation_matrix: glm::i...
code_fim
hard
{ "lang": "rust", "repo": "Magnuti/TDT4195-Visual-Computing", "path": "/graphics/Assignment_3/gloom-rs/src/scene_graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub vao_id: u32, pub index_count: i32, pub children: Vec<*mut SceneNode>, } impl SceneNode { pub fn new() -> Node { ManuallyDrop::new(Pin::new(Box::new(SceneNode { position: glm::zero(), rotation: glm::zero(), scale: glm::vec3(1.0, 1.0, 1.0), ...
code_fim
hard
{ "lang": "rust", "repo": "Magnuti/TDT4195-Visual-Computing", "path": "/graphics/Assignment_3/gloom-rs/src/scene_graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Magnuti/TDT4195-Visual-Computing path: /graphics/Assignment_3/gloom-rs/src/scene_graph.rs extern crate nalgebra_glm as glm; use std::mem::ManuallyDrop; use std::pin::Pin; // Used to crete an unholy abomination upon which you should not cast your gaze. // This ended up being a necessity due to ...
code_fim
hard
{ "lang": "rust", "repo": "Magnuti/TDT4195-Visual-Computing", "path": "/graphics/Assignment_3/gloom-rs/src/scene_graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !all && duration.as_secs() > 0 { if (Local::now() - solve.created).to_std().unwrap() > duration { continue; } } else if !all { if let Some(last_session) = &last_session { if &solve.session != last_session { ...
code_fim
hard
{ "lang": "rust", "repo": "D0ntPanic/tpscube", "path": "/tools/analysis/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let solution: Option<CubeWithSolution> = solve.into(); if let Some(solution) = solution { let analysis = CFOPPartialAnalysis::analyze(&solution); println!("Solve in {}ms\n{}", solve.time, analysis); } } }<|fim_prefix|>// repo: D0ntPanic/tpscube path: /t...
code_fim
hard
{ "lang": "rust", "repo": "D0ntPanic/tpscube", "path": "/tools/analysis/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: D0ntPanic/tpscube path: /tools/analysis/src/main.rs use chrono::Local; use clap::{App, Arg}; use std::str::FromStr; use std::time::Duration; use tpscube_core::{CFOPPartialAnalysis, CubeWithSolution, History}; #[tokio::main] async fn main() { let matches = App::new("TPS Cube Analysis") ...
code_fim
hard
{ "lang": "rust", "repo": "D0ntPanic/tpscube", "path": "/tools/analysis/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Test clippy::cast_lossless with casts to floating-point types 1i8 as f32; 1i8 as f64; 1u8 as f32; 1u8 as f64; 1i16 as f32; 1i16 as f64; 1u16 as f32; 1u16 as f64; 1i32 as f64; 1u32 as f64; } // The lint would suggest using `f64::from(input)` here but the `XX:...
code_fim
medium
{ "lang": "rust", "repo": "codegrande/rust-clippy", "path": "/tests/ui/cast_lossless_float.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, // so we skip the lint if the expression is in a const fn. // See #3656 const fn abc(input: f32) -> f64 { input as f64 }<|fim_prefix|>// repo: codegrande/rust-clippy path: /tests/ui/cast_lossless_float.r...
code_fim
hard
{ "lang": "rust", "repo": "codegrande/rust-clippy", "path": "/tests/ui/cast_lossless_float.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codegrande/rust-clippy path: /tests/ui/cast_lossless_float.rs // run-rustfix #![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)] #![warn(clippy::cast_lossless)] <|fim_suffix|> // Test clippy::cast_lossless with casts to floating-point types 1i8 as f32; 1i8 as f64;...
code_fim
medium
{ "lang": "rust", "repo": "codegrande/rust-clippy", "path": "/tests/ui/cast_lossless_float.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakobbotsch/concordium-rust-smart-contracts path: /examples/piggy-bank/part1/src/lib.rs //! Piggy bank smart contract. //! //! Allows anyone to insert GTU, but only the owner can "smash" it and //! retrieve the GTU. Prevents more GTU to be inserted after being smashed. //! //! This smart contrac...
code_fim
hard
{ "lang": "rust", "repo": "jakobbotsch/concordium-rust-smart-contracts", "path": "/examples/piggy-bank/part1/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Insert some GTU into a piggy bank, allowed by anyone. #[receive(contract = "PiggyBank", name = "insert", payable)] fn piggy_insert<A: HasActions>( _ctx: &impl HasReceiveContext, _amount: Amount, state: &mut PiggyBankState, ) -> ReceiveResult<A> { // Ensure the piggy bank has not been s...
code_fim
medium
{ "lang": "rust", "repo": "jakobbotsch/concordium-rust-smart-contracts", "path": "/examples/piggy-bank/part1/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jblindsay/whitebox-tools path: /whitebox-common/src/structures/n_minimizer.rs /* This code is part of the WhiteboxTools geospatial analysis library. Authors: Dr. John Lindsay Last Modified: 13/09/2018 License: MIT */ /// NMinimizer is can be used to find the 'n' lowest values in a set of values...
code_fim
hard
{ "lang": "rust", "repo": "jblindsay/whitebox-tools", "path": "/whitebox-common/src/structures/n_minimizer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns all of the minima as a vector. pub fn get_minima(&self) -> Vec<T> { self.values.clone() } /// Until *n* values have been inserted, the current minima /// set size < *n*. After *n* values have been inserted size = *n*. pub fn size(&self) -> usize { self....
code_fim
hard
{ "lang": "rust", "repo": "jblindsay/whitebox-tools", "path": "/whitebox-common/src/structures/n_minimizer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn fn_(functions: &mut FnvHashMap<Identifier, Function>) -> i32 { print_functions(functions); SUCCESS }<|fim_prefix|>// repo: schedutron/ion-1 path: /src/lib/builtins/functions.rs use fnv::FnvHashMap; use shell::flow_control::Function; use shell::status::*; use std::io::{self, Write}; ...
code_fim
hard
{ "lang": "rust", "repo": "schedutron/ion-1", "path": "/src/lib/builtins/functions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: schedutron/ion-1 path: /src/lib/builtins/functions.rs use fnv::FnvHashMap; use shell::flow_control::Function; use shell::status::*; use std::io::{self, Write}; use types::Identifier; fn print_functions(functions: &FnvHashMap<Identifier, Function>) { <|fim_suffix|>pub(crate) fn fn_(functions: &m...
code_fim
hard
{ "lang": "rust", "repo": "schedutron/ion-1", "path": "/src/lib/builtins/functions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FallDownTheSystem/aoc-2020 path: /src/bin/day6.rs use std::collections::{HashMap, HashSet}; use std::io; use std::io::prelude::*; use std::iter::FromIterator; fn unique_answers(input: &str) -> usize { input .split("\n\n") .map(|x| HashSet::<char>::from_iter(x.chars().filter(|&x| !x.is_whit...
code_fim
medium
{ "lang": "rust", "repo": "FallDownTheSystem/aoc-2020", "path": "/src/bin/day6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = "\ abc a b c ab ac a a a a b"; assert_eq!(11, unique_answers(&input)); assert_eq!(6, same_answers(&input)); } fn main() { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer).unwrap(); println!("{}", unique_answers(&buffer)); println!("{}", same_answers(&buffer...
code_fim
hard
{ "lang": "rust", "repo": "FallDownTheSystem/aoc-2020", "path": "/src/bin/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: freizeit/exercises path: /cj-a-store-credit/rust/main.rs #[crate_id = "main"]; #[crate_type="bin"]; //! A program solving //! //! http://code.google.com/codejam/contest/dashboard?c=351101#s=p0 //! //! The test cases are contained in a file whose path is to be specified on //! the command l...
code_fim
hard
{ "lang": "rust", "repo": "freizeit/exercises", "path": "/cj-a-store-credit/rust/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> do spawn || { let result = ::calculate::find_items(i_is_mutable_and_cannot_be_passed, l1.trim(), l2.trim(), l3.trim()); my_chan.send(result); } i += 1; } let mut results = port.iter(); i = 0; while i < num_tasks { let res = results.n...
code_fim
hard
{ "lang": "rust", "repo": "freizeit/exercises", "path": "/cj-a-store-credit/rust/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let role = config.role.clone(); let prometheus_registry = config.prometheus_registry().cloned(); let rpc_extensions_builder = { let client = client.clone(); let pool = transaction_pool.clone(); Box::new(move |deny_unsafe, _| { let deps = crate::rpc::FullDeps { client: client.clone(), poo...
code_fim
hard
{ "lang": "rust", "repo": "gitwithterrence/sybil", "path": "/node/src/service.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); let select_chain = sc_consensus::LongestChain::new(backend.clone()); let address = MultiSigner::from(sp_keyring::Sr25519Keyring::Alice.public()) .into_account() .encode(); let (worker, author...
code_fim
hard
{ "lang": "rust", "repo": "gitwithterrence/sybil", "path": "/node/src/service.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitwithterrence/sybil path: /node/src/service.rs //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. use codec::Encode; use rand::RngCore; use sc_client_api::ExecutorProvider; use sc_consensus::LongestChain; use sc_consensus_pow::PowBlockImport; use sc_exe...
code_fim
hard
{ "lang": "rust", "repo": "gitwithterrence/sybil", "path": "/node/src/service.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>fn read_json(path: impl AsRef<Path>) -> String { std::fs::read_to_string(path.as_ref()).expect("failed in reading file") } fn main() { logger::init(); let cfg = Config::from_args(); let krate = serde_json::from_str::<Crate>(&read_json(cfg.index)) .expect("failed in deserializing ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/roogle", "path": "/roogle/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cfg = Config::from_args(); let krate = serde_json::from_str::<Crate>(&read_json(cfg.index)) .expect("failed in deserializing crate"); let qe = QueryExecutor::new(krate); let mut rl = Editor::<()>::new(); loop { let readline = rl.readline("> "); match readl...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/roogle", "path": "/roogle/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/roogle path: /roogle/src/main.rs use core::panic; use std::path::{Path, PathBuf}; use env_logger as logger; use rustdoc_types::Crate; use rustyline::error::ReadlineError; use rustyline::Editor; use structopt::StructOpt; use roogle_engine::{exec::QueryExecutor, parse::parse_query}; #[d...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/roogle", "path": "/roogle/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl INode for Stdout { fn read_at(&self, _offset: usize, _buf: &mut [u8]) -> Result<usize> { unimplemented!() } fn write_at(&self, _offset: usize, buf: &[u8]) -> Result<usize> { use core::str; //we do not care the utf-8 things, we just want to print it! let s =...
code_fim
hard
{ "lang": "rust", "repo": "magicpan-risc-v/rcore_plus", "path": "/kernel/src/fs/stdio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.can_read() { buf[0] = self.pop() as u8; Ok(1) } else { Err(FsError::Again) } } fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result<usize> { unimplemented!() } fn poll(&self) -> Result<PollStatus> { Ok...
code_fim
hard
{ "lang": "rust", "repo": "magicpan-risc-v/rcore_plus", "path": "/kernel/src/fs/stdio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magicpan-risc-v/rcore_plus path: /kernel/src/fs/stdio.rs //! Implement INode for Stdin & Stdout use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc}; use core::any::Any; use rcore_fs::vfs::*; use super::ioctl::*; use crate::sync::Condvar; use crate::sync::SpinNoIrqLock as ...
code_fim
hard
{ "lang": "rust", "repo": "magicpan-risc-v/rcore_plus", "path": "/kernel/src/fs/stdio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: da-x/zola path: /components/templates/src/filters.rs use std::collections::HashMap; use std::hash::BuildHasher; use base64::{decode, encode}; use config::Config; use rendering::{render_content, RenderContext}; use tera::{to_value, try_get_value, Filter as TeraFilter, Result as TeraResult, Value...
code_fim
hard
{ "lang": "rust", "repo": "da-x/zola", "path": "/components/templates/src/filters.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // from https://tools.ietf.org/html/rfc4648#section-10 let tests = vec![ ("", ""), ("f", "Zg=="), ("fo", "Zm8="), ("foo", "Zm9v"), ("foob", "Zm9vYg=="), ("fooba", "Zm9vYmE="), ("foobar", "Zm9vYmFy"), ...
code_fim
hard
{ "lang": "rust", "repo": "da-x/zola", "path": "/components/templates/src/filters.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn markdown_filter_inline() { let mut args = HashMap::new(); args.insert("inline".to_string(), to_value(true).unwrap()); let result = MarkdownFilter::new(Config::default()).filter( &to_value(&"Using `map`, `filter`, and `fold` instead of `for`").unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "da-x/zola", "path": "/components/templates/src/filters.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GREsau/okapi path: /examples/secure_request_guard/src/http_auth.rs //! ------ HTTP `Authorization` header ------ use rocket::serde::json::Json; use rocket::{ get, http::Status, request::{self, FromRequest, Outcome}, }; use rocket_okapi::okapi::openapi3::{ Object, SecurityRequire...
code_fim
hard
{ "lang": "rust", "repo": "GREsau/okapi", "path": "/examples/secure_request_guard/src/http_auth.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// # HTTP `Authorization` header /// /// The token is: `mytoken` /// This is a common way of checking the authentication. /// (make sure this is only sent over HTTPS, don't want secrets to leak) #[openapi] #[get("/http_auth")] pub fn http_auth(token: HttpAuth) -> Json<&'static str> { // Use api key ...
code_fim
hard
{ "lang": "rust", "repo": "GREsau/okapi", "path": "/examples/secure_request_guard/src/http_auth.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> str::from_utf8(&self.0).expect("ResRef contains non UTF-8 string") } } impl<'a> From<&'a str> for ResRef { #[inline] fn from(str: &'a str) -> Self { ResRef(str.as_bytes().to_owned()) } } impl FromStr for ResRef { type Err = (); #[inline] fn from_str(str: &str) -> Result<Self, Self::Err>...
code_fim
hard
{ "lang": "rust", "repo": "Mingun/serde-gff", "path": "/src/resref.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<&'a str> for ResRef { #[inline] fn from(str: &'a str) -> Self { ResRef(str.as_bytes().to_owned()) } } impl FromStr for ResRef { type Err = (); #[inline] fn from_str(str: &str) -> Result<Self, Self::Err> { Ok(str.into()) } }<|fim_prefix|>// repo: Mingun/serde-gff path: /src/resre...
code_fim
medium
{ "lang": "rust", "repo": "Mingun/serde-gff", "path": "/src/resref.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mingun/serde-gff path: /src/resref.rs //! Содержит реализацию структуры, описывающей ссылку на ресурс и реализацию типажей для //! конвертации других типов данных в ссылку и обратно use std::fmt; use std::str::{self, FromStr, Utf8Error}; use std::string::FromUtf8Error; /// Представляет ссылку ...
code_fim
hard
{ "lang": "rust", "repo": "Mingun/serde-gff", "path": "/src/resref.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Resolve the path relative to the given base returning a new path pub fn resolve<S: Into<String>>(base: &VPath, path: S) -> Box<VPath> { base.resolve(&path.into()) } /// An abstract file object pub trait VFile: Read + Write + Seek + Debug {} impl<T> VFile for T where T: Read + Write + Seek + Debu...
code_fim
hard
{ "lang": "rust", "repo": "JosquinFrei/rust-vfs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Check if the file existst fn exists(&self) -> bool; /// Get the file's metadata fn metadata(&self) -> Result<Box<VMetadata>>; /// Retrieve the path entries in this path fn read_dir(&self) -> Result<Box<Iterator<Item = Result<Box<VPath>>>>>; /// Retrieve a string represe...
code_fim
hard
{ "lang": "rust", "repo": "JosquinFrei/rust-vfs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JosquinFrei/rust-vfs path: /src/lib.rs //! Virtual file system abstraction //! //! The virtual file system abstraction generalizes over file systems and allow using //! different filesystem implementations (i.e. an in memory implementation for unit tests) //! //! A virtual filesystem consists of...
code_fim
hard
{ "lang": "rust", "repo": "JosquinFrei/rust-vfs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/atats path: /src/instruction/mnemonic.rs use crate::{ error::OpcodeError, instruction::{itype::Type, opcode}, }; #[allow(unused_macros)] macro_rules! mnemonic_opcodes { ( match (bits_a, bits_b, bits_c) { $(( $pat_a:literal $(| $pats_a:lite...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/atats", "path": "/src/instruction/mnemonic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mnemonic_opcodes! { match (bits_a, bits_b, bits_c) { (0, 0, 0) => Brk, (0, 2, 0) => Php, (0, 4, 0) => Bpl, (0, 6, 0) => Clc, (0, 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7, 1) => Ora, (0, 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7, 2) => Asl, (1, 0, 0) => Jsr, (1,...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/atats", "path": "/src/instruction/mnemonic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Mnemonic { pub fn instr_type(self) -> Type { match self { Mnemonic::Ora | Mnemonic::And | Mnemonic::Eor | Mnemonic::Adc | Mnemonic::Lda | Mnemonic::Cmp | Mnemonic::Sbc => Type::Aop, Mnemonic::B...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/atats", "path": "/src/instruction/mnemonic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let dir_to_light = glm::normalize(&Vec3::new(1.0, 1.0, 1.0)); // mock directional light it.for_each(|(r, p): (Ray, &mut Color3)| { if let Some(hit) = world.cast(&r) { let color = hit.material.shade(&r, &hit.normal, &dir_to_light); if color.r <= 1...
code_fim
hard
{ "lang": "rust", "repo": "wrenby/raytrace-rs", "path": "/src/screen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wrenby/raytrace-rs path: /src/screen.rs use crate::math::*; use crate::{Camera, World, Ray, Color3}; use nalgebra_glm as glm; use rgb::RGB8; #[cfg(feature="parallel")] use rayon::prelude::*; use std::iter::Iterator as Iter; pub struct Screen { pub width: usize, pub height: usize, } imp...
code_fim
hard
{ "lang": "rust", "repo": "wrenby/raytrace-rs", "path": "/src/screen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: korken89/micromath path: /src/lib.rs //! Embedded-friendly (i.e. `#![no_std]`) math library featuring fast, safe //! floating point approximations for common arithmetic operations, as well as //! 2D and 3D vector types, statistical analysis functions, and quaternions. //! //! ## Floating point a...
code_fim
hard
{ "lang": "rust", "repo": "korken89/micromath", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "vector")] #[cfg_attr(docsrs, doc(cfg(feature = "vector")))] pub mod vector; mod f32ext; mod float; #[cfg(feature = "quaternion")] mod quaternion; pub use crate::{f32ext::F32Ext, float::F32}; #[cfg(feature = "quaternion")] pub use crate::quaternion::Quaternion; #[cfg(feature = "num-tra...
code_fim
hard
{ "lang": "rust", "repo": "korken89/micromath", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielKeep/rust-custom-derive path: /enum_derive/tests/enum_from_inner.rs /* Copyright ⓒ 2016 macro-attr contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-custom-derive", "path": "/enum_derive/tests/enum_from_inner.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Into::<Value>::into(()), Value::Unit(())); assert_eq!(Into::<Value>::into(42i64), Value::Int(42)); assert_eq!(Into::<Value>::into("fry"), Value::Str("fry")); assert_eq!({ let v: Value = From::from(()); v }, Value::Unit(())); assert_eq!({ let v: Value = From::from(42i64); v ...
code_fim
medium
{ "lang": "rust", "repo": "DanielKeep/rust-custom-derive", "path": "/enum_derive/tests/enum_from_inner.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_from_inner() { assert_eq!(Into::<Value>::into(()), Value::Unit(())); assert_eq!(Into::<Value>::into(42i64), Value::Int(42)); assert_eq!(Into::<Value>::into("fry"), Value::Str("fry")); assert_eq!({ let v: Value = From::from(()); v }, Value::Unit(())); assert_eq!({ let v...
code_fim
medium
{ "lang": "rust", "repo": "DanielKeep/rust-custom-derive", "path": "/enum_derive/tests/enum_from_inner.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssanderson/aoc2019 path: /src/problem17.rs /*! --- Day 17: Set and Forget --- An early warning system detects an incoming solar flare and automatically activates the ship's electromagnetic shield. Unfortunately, this has cut off the Wi-Fi for many small robots that, unaware of the impending da...
code_fim
hard
{ "lang": "rust", "repo": "ssanderson/aoc2019", "path": "/src/problem17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use crate::grid::{Coord, Grid}; use crate::intcode::{Program, StaticIO}; use crate::utils::{ProblemInput, ProblemResult}; mod cell { use std::collections::HashMap; use std::convert::TryFrom; use std::fmt; use crate::grid::{Coord, Direction, Grid, Turn}; const HASH: i64 = '#' as i64; ...
code_fim
hard
{ "lang": "rust", "repo": "ssanderson/aoc2019", "path": "/src/problem17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>trait MyFrom<T> { fn from(other: T) -> Self; } impl<T> MyFrom<()> for T { default fn from(other: ()) -> T { panic!(); } } impl<T: X> MyFrom<<A<T> as Z>::Assoc> for T { fn from(other: ()) -> T { panic!(); } } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /t...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/specialization/min_specialization/specialize-associated-type.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> MyFrom<()> for T { default fn from(other: ()) -> T { panic!(); } } impl<T: X> MyFrom<<A<T> as Z>::Assoc> for T { fn from(other: ()) -> T { panic!(); } } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/specialization/min_specialization/special...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/specialization/min_specialization/specialize-associated-type.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/specialization/min_specialization/specialize-associated-type.rs // Another regression test for #109815. // check-pass #![feature(min_specialization)] #![feature(rustc_attrs)] #[rustc_specialization_trait] trait X {} trait Z { type Assoc: X; } struct A<T>(T);...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/specialization/min_specialization/specialize-associated-type.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }