text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let req: http::Request<Vec<u8>> = discover_homeserver::Request::new() .try_into_http_request( "https://homeserver.tld", SendAccessToken::None, &[MatrixVersion::V1_1], ) .unwrap(); assert_eq!(*req.headers(), HeaderMap::default()); }<|fim_...
code_fim
medium
{ "lang": "rust", "repo": "ruma/ruma", "path": "/crates/ruma-client-api/tests/headers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Schr3da/wasm-map-generator-demo path: /src/lib.rs extern crate sdl2; extern crate rand; extern crate num; pub mod const<|fim_suffix|>pub mod input; pub mod generator; pub mod renderer; pub mod loader; pub mod primitives; pub mod ui; pub mod app; #[cfg(test)] pub mod tests;<|fim_middle|>ants; p...
code_fim
medium
{ "lang": "rust", "repo": "Schr3da/wasm-map-generator-demo", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod input; pub mod generator; pub mod renderer; pub mod loader; pub mod primitives; pub mod ui; pub mod app; #[cfg(test)] pub mod tests;<|fim_prefix|>// repo: Schr3da/wasm-map-generator-demo path: /src/lib.rs extern crate sdl2; extern crate rand; extern crate num; pub mod const<|fim_middle|>ants; p...
code_fim
medium
{ "lang": "rust", "repo": "Schr3da/wasm-map-generator-demo", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scottpchow23/rust_showcase path: /src/models/Course.rs use serde::{Deserialize, Serialize}; #[path = "CourseSection.rs"] mod course_section; #[path = "GeneralEducation.rs"] mod general_education; #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub stru<|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "scottpchow23/rust_showcase", "path": "/src/models/Course.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> String, pub on_line_course: bool, pub quarter: String, pub subject_area: String, pub title: String, pub units_fixed: Option<f32>, pub units_variable_high: Option<f32>, pub units_variable_low: Option<f32>, }<|fim_prefix|>// repo: scottpchow23/rust_showcase path: /src/models/Co...
code_fim
hard
{ "lang": "rust", "repo": "scottpchow23/rust_showcase", "path": "/src/models/Course.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(response.status().is_success()); let text = response .text() .await .expect("couldn't handle response text"); assert_eq!(text, "Hello, foo"); }<|fim_prefix|>// repo: terakilobyte/zero2prod path: /tests/hello_name.rs mod helpers; use helpers::spawn_app; #[actix_...
code_fim
medium
{ "lang": "rust", "repo": "terakilobyte/zero2prod", "path": "/tests/hello_name.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: terakilobyte/zero2prod path: /tests/hello_name.rs mod helpers; use helpers::spawn_app; #[actix_rt::test] async fn health_check_works() { let addr = spawn_app().await; let client = reqwest::Client::new(); <|fim_suffix|> assert!(response.status().is_success()); let text = response ...
code_fim
medium
{ "lang": "rust", "repo": "terakilobyte/zero2prod", "path": "/tests/hello_name.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cosenmarco/softeelab path: /src/model/core.rs use std::collections::HashMap; use std::sync::mpsc::{Sender, Receiver, TryRecvError}; #[derive(Copy, Clone, Debug)] pub enum SystemEvent { Start(u64), Stop } #[derive(Copy, Clone, Debug)] pub enum EventType { Trigger } #[derive(Copy, C...
code_fim
hard
{ "lang": "rust", "repo": "cosenmarco/softeelab", "path": "/src/model/core.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct OutputPort { senders: Vec<Sender<Event>> } pub struct InputPort<T> { receiver: Option<Receiver<T>> } impl OutputPort { pub fn new() -> Self { OutputPort { senders: Vec::new() } } pub fn add_sender(&mut self, sender: Sender<Event>) { sel...
code_fim
hard
{ "lang": "rust", "repo": "cosenmarco/softeelab", "path": "/src/model/core.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub type BoxedBlock = Box<dyn Block + Send>; pub struct OutputPort { senders: Vec<Sender<Event>> } pub struct InputPort<T> { receiver: Option<Receiver<T>> } impl OutputPort { pub fn new() -> Self { OutputPort { senders: Vec::new() } } pub fn add_sende...
code_fim
hard
{ "lang": "rust", "repo": "cosenmarco/softeelab", "path": "/src/model/core.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexs-sh/dummy-central-system path: /src/x509.rs use std::fs::{create_dir_all, File}; use std::io::prelude::*; use std::process::Command; use std::string::String; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(PartialEq)] pub enum Format { DER, PEM, } pub trait CertificationAuthorit...
code_fim
hard
{ "lang": "rust", "repo": "alexs-sh/dummy-central-system", "path": "/src/x509.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", self.read_key(pair.get_key())); println!("{}", self.read_certificate(pair.get_certificate())); self.certificates.push(pair); Ok(()) } pub fn get_workdir(&self) -> &str { self.settings.directory.as_str() } pub fn read_key(&self, fil...
code_fim
hard
{ "lang": "rust", "repo": "alexs-sh/dummy-central-system", "path": "/src/x509.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn offset(&self, offset: usize) -> Span { Span { start: self.start - offset, end: self.end - offset, } } }<|fim_prefix|>// repo: stormrust/engine-q1 path: /src/span.rs #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Span { pub start: usize, ...
code_fim
medium
{ "lang": "rust", "repo": "stormrust/engine-q1", "path": "/src/span.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn unknown() -> Span { Span { start: 0, end: 0 } } pub fn offset(&self, offset: usize) -> Span { Span { start: self.start - offset, end: self.end - offset, } } }<|fim_prefix|>// repo: stormrust/engine-q1 path: /src/span.rs #[derive(Clon...
code_fim
medium
{ "lang": "rust", "repo": "stormrust/engine-q1", "path": "/src/span.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stormrust/engine-q1 path: /src/span.rs #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Span { pub start: usize, pub end: usize, } impl Span { pub fn new(start: usize, end: usize) -> Span { Span { start, end } } <|fim_suffix|> pub fn offset(&self, offset: usiz...
code_fim
medium
{ "lang": "rust", "repo": "stormrust/engine-q1", "path": "/src/span.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn ip_addr() { let v4 = match "1.2.3.4".parse() { Ok(IpAddr::V4(addr)) => addr, _ => panic!("invalid ipv4 addr"), }; let v6 = match "2404:6800:4004:814::200e".parse() { Ok(IpAddr::V6(addr)) => addr, _ => panic!("inv...
code_fim
hard
{ "lang": "rust", "repo": "wg/irongate", "path": "/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let events = [ "sshd[92368]: Did not receive identification string from 128.61.240.66", "sshd[92736]: input_userauth_request: invalid user postgres [preauth]", "sshd[56043]: Received disconnect from 128.61.240.66: 11: disconnected by user", ]; for event in &events { ...
code_fim
hard
{ "lang": "rust", "repo": "wg/irongate", "path": "/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wg/irongate path: /src/tests.rs // Copyright (C) 2015 - Will Glozer. All rights reserved. use chrono::{DateTime, UTC, TimeZone}; const REFERENCE: &'static str = "2000-01-02 03:04:05 +00:00"; #[test] fn timestamp_ok() { assert_eq!(timestamp("Jan 2 03:04:05"), UTC.ymd(2000, 01, 02).and_hm...
code_fim
hard
{ "lang": "rust", "repo": "wg/irongate", "path": "/src/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: acolley/toggler path: /src/main.rs // Need a macro_use so that macros are brought // in globally for use in crate::database::schema #[macro_use] extern crate diesel; mod app; mod database; mod domain; mod project; mod toggle; use actix::SyncArbiter; use actix_web::middleware::Logger; use actix...
code_fim
medium
{ "lang": "rust", "repo": "acolley/toggler", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> app::create("db.sqlite")?.bind("127.0.0.1:8088")?.start(); let _ = sys.run(); Ok(()) }<|fim_prefix|>// repo: acolley/toggler path: /src/main.rs // Need a macro_use so that macros are brought // in globally for use in crate::database::schema #[macro_use] extern crate diesel; mod app; mod da...
code_fim
hard
{ "lang": "rust", "repo": "acolley/toggler", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct TriggeredInterrupt { number: NonZeroU32, } impl TriggeredInterrupt { pub fn number(&self) -> u32 { self.number.get() } } unsafe impl Send for TriggeredInterrupt {} unsafe impl Sync for TriggeredInterrupt {}<|fim_prefix|>// repo: boylede/five_os path: /crates/fiveos_virtio...
code_fim
hard
{ "lang": "rust", "repo": "boylede/five_os", "path": "/crates/fiveos_virtio/src/plic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boylede/five_os path: /crates/fiveos_virtio/src/plic.rs use core::num::NonZeroU32; const ENABLE: usize = 0x0c00_2000; const PRIORITY: usize = 0x0c00_0000; const PENDING: usize = 0x0c00_1000; const THRESHOLD: usize = 0x0c20_0000; const CLAIM_COMPLETE: usize = 0x0c20_0004; <|fim_suffix|>pub stru...
code_fim
hard
{ "lang": "rust", "repo": "boylede/five_os", "path": "/crates/fiveos_virtio/src/plic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let _srt = performance.now(); let canvas = document.create_element("canvas")?; canvas.set_attribute("display", "none"); let canvas: web_sys::HtmlCanvasElement = canvas .dyn_into::<web_sys::HtmlCanvasElement>() .map_err(|_| ()) .unwrap(); let context = canvas ...
code_fim
hard
{ "lang": "rust", "repo": "fruitbox12/wasm-fingerprint", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fruitbox12/wasm-fingerprint path: /src/lib.rs use crc::{crc32, Hasher32}; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; <|fim_suffix|>#[wasm_bindgen] // pub fn make_finger...
code_fim
medium
{ "lang": "rust", "repo": "fruitbox12/wasm-fingerprint", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fetlife/redis-analyzer path: /src/result_formatters/plain.rs use humantime::format_duration; use indicatif::HumanBytes; use regex::Regex; use std::cmp::max; use crate::analyzer::Result; use crate::config::Config; use crate::key_prefix::KeyPrefix; struct FormattingOptions { key_column_width...
code_fim
hard
{ "lang": "rust", "repo": "fetlife/redis-analyzer", "path": "/src/result_formatters/plain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Took {}", format_duration(result.took)); println!( "{:indent$}Keys Count{:indenx$}Memory Usage", "", "", indent = options.key_column_width, indenx = options.count_column_width - 9, ); print_tree( &options, &result.root_pref...
code_fim
hard
{ "lang": "rust", "repo": "fetlife/redis-analyzer", "path": "/src/result_formatters/plain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn add(&mut self) { self.tick += 1; } pub fn count(&self) -> usize { self.tick } }<|fim_prefix|>// repo: jGundermann/wasm-compare path: /wasmpack/src/lib.rs mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the g...
code_fim
medium
{ "lang": "rust", "repo": "jGundermann/wasm-compare", "path": "/wasmpack/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jGundermann/wasm-compare path: /wasmpack/src/lib.rs mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; ...
code_fim
medium
{ "lang": "rust", "repo": "jGundermann/wasm-compare", "path": "/wasmpack/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimeys/tokio-solicit path: /src/client/tokio_layer.rs Also exposes the `H2ClientTokioProto` that allows an existing `Io` instance to be bound //! to the HTTP/2 Tokio transport, as implemented by `H2ClientTokioTransport`. use super::{ Http2Error, TokioSyncError, HttpRequestHeaders, ...
code_fim
hard
{ "lang": "rust", "repo": "pimeys/tokio-solicit", "path": "/src/client/tokio_layer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimeys/tokio-solicit path: /src/client/tokio_layer.rs seChunk) { self.result_stream.borrow_mut().push_back((self.request_id, chunk)); } } /// A helper struct that exposes the receiving end of the shared buffer of `ResponseChunk`s that /// the `H2ClientTokioTransport` should yield. s...
code_fim
hard
{ "lang": "rust", "repo": "pimeys/tokio-solicit", "path": "/src/client/tokio_layer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !self.has_pending_request_data() { // No more pending request data -- we're done sending all requests. return Ok(Async::Ready(())); } trace!("preparing a data frame"); let has_data = self.try_write_next_data()?; if has_data { ...
code_fim
hard
{ "lang": "rust", "repo": "pimeys/tokio-solicit", "path": "/src/client/tokio_layer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn real_main() -> i32 { vout!("cmd: {:?}", env::current_exe()); let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); if args.flag_verbose { log::set_verbose(); } vout!("verbose mode\nargs:{:?}\n", args); let file = L...
code_fim
hard
{ "lang": "rust", "repo": "itscomputers/leema", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itscomputers/leema path: /src/main.rs #![deny(warnings)] #![allow(dead_code)] extern crate docopt; extern crate libc; #[macro_use] extern crate mopa; extern crate bytes; extern crate futures; extern crate hyper; extern crate rand; extern crate rustc_serialize; extern crate tokio; extern crate t...
code_fim
hard
{ "lang": "rust", "repo": "itscomputers/leema", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let main_result = if args.arg_cmd == "tokens" { let modtxt = inter.read_module(&modkey); let toks = ModuleSource::read_tokens(&modtxt); println!("{:?}\n", toks); Val::Int(0) } else if args.arg_cmd == "ast" { let modtxt = inter.read_module(&modkey); l...
code_fim
hard
{ "lang": "rust", "repo": "itscomputers/leema", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> System::events().iter().any(|a| a.event == expected_event) } #[test] fn it_can_claim_a_domain_name() { new_test_ext().execute_with(|| { let domain = b"janislav.eth"; assert_ok!(Domain::register(Origin::signed(200), domain.to_vec())); let expected = Domain::domains(domain.to_vec()); assert_eq...
code_fim
hard
{ "lang": "rust", "repo": "Janislav/pallet-domainname", "path": "/src/tests.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Janislav/pallet-domainname path: /src/tests.rs use super::*; use crate as domainname; use sp_core::H256; use frame_support::{ parameter_types, assert_ok, assert_noop, }; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, testing::Header, }; type UncheckedExtrinsic = frame_system::mo...
code_fim
hard
{ "lang": "rust", "repo": "Janislav/pallet-domainname", "path": "/src/tests.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>fn min<T>(v1: T, v2: T) -> Option<T> where T: PartialOrd, { match v1.partial_cmp(&v2)? { Ordering::Greater => Some(v2), _ => Some(v1), } } fn max<T>(v1: T, v2: T) -> Option<T> where T: PartialOrd, { match v1.partial_cmp(&v2)? { Ordering::Less => Some(v2), ...
code_fim
hard
{ "lang": "rust", "repo": "Hakuyume/rect-rs", "path": "/src/rect.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hakuyume/rect-rs path: /src/rect.rs use std::cmp::{Ordering, PartialOrd}; use std::ops::{Add, Div, Mul, Sub}; pub trait Rect<T> { fn top(&self) -> T; fn left(&self) -> T; fn bottom(&self) -> T; fn right(&self) -> T; fn height(&self) -> Option<T> <|fim_suffix|> self.2...
code_fim
hard
{ "lang": "rust", "repo": "Hakuyume/rect-rs", "path": "/src/rect.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kazcw/RustCrypto-hashes path: /blake/tests/lib.rs extern crate blake; extern crate digest; use digest::Digest; fn read_files(path: &str) -> (Vec<u8>, Vec<u8>) { use std::io::Read; let mut input = std::fs::File::open(format!("tests/data/{}.input.bin", path)).unwrap(); let mut output...
code_fim
hard
{ "lang": "rust", "repo": "kazcw/RustCrypto-hashes", "path": "/blake/tests/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn blake_384() { for path in &["blake_384/test1", "blake_384/test2"] { let (input, output) = read_files(path); let hash = blake::Blake384::digest(&input); assert_eq!(&hash[..], &output[..]); } } #[test] fn blake_512() { for path in &["blake_512/test1", "blake_5...
code_fim
hard
{ "lang": "rust", "repo": "kazcw/RustCrypto-hashes", "path": "/blake/tests/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> connection.execute(query, &[]).unwrap(); connection.execute("INSERT INTO migrations(id) VALUES ($1)", &[&id]).unwrap(); } } struct Migration { id: &'static str, query: &'static str, } fn get_migrations() -> Vec<Migration> { vec![ Migration { id: "0", ...
code_fim
hard
{ "lang": "rust", "repo": "tomaka/example-tiny-http", "path": "/src/database/migration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomaka/example-tiny-http path: /src/database/migration.rs use postgres::Connection; /// Ensures that the database has the correct schema. pub fn migrate(connection: &Connection) { connection.execute(r#" CREATE TABLE IF NOT EXISTS migrations ( id VARCHAR(64) PRIMARY KEY N...
code_fim
hard
{ "lang": "rust", "repo": "tomaka/example-tiny-http", "path": "/src/database/migration.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct Migration { id: &'static str, query: &'static str, } fn get_migrations() -> Vec<Migration> { vec![ Migration { id: "0", query: r#" CREATE TABLE users ( id SERIAL PRIMARY KEY, login VARCHAR(128), ...
code_fim
hard
{ "lang": "rust", "repo": "tomaka/example-tiny-http", "path": "/src/database/migration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Wrapper around [`tokio::fs::ReadDir::poll_next_entry`]. pub fn poll_next_entry(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<Option<DirEntry>>> { Poll::Ready(match ready!(self.tokio.poll_next_entry(cx)) { Ok(entry) => Ok(entry.map(|e| DirEntry { tokio: e })), ...
code_fim
hard
{ "lang": "rust", "repo": "andrewhickman/fs-err", "path": "/src/tokio/read_dir.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewhickman/fs-err path: /src/tokio/read_dir.rs use crate::errors::{Error, ErrorKind}; use std::ffi::OsString; use std::fs::{FileType, Metadata}; use std::io; use std::path::{Path, PathBuf}; use std::task::{ready, Context, Poll}; use tokio::fs; /// Wrapper for [`tokio::fs::read_dir`]. #[cfg_a...
code_fim
hard
{ "lang": "rust", "repo": "andrewhickman/fs-err", "path": "/src/tokio/read_dir.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Wrapper around [`tokio::fs::DirEntry::file_name`]. pub fn file_name(&self) -> OsString { self.tokio.file_name() } /// Wrapper around [`tokio::fs::DirEntry::metadata`]. pub async fn metadata(&self) -> io::Result<Metadata> { self.tokio .metadata() ...
code_fim
hard
{ "lang": "rust", "repo": "andrewhickman/fs-err", "path": "/src/tokio/read_dir.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajiahamed/icefoss path: /code2/session2/mcp3008/src/main2.rs extern crate spidev; use std::io; use spidev::{Spidev, SpidevOptions, SpidevTransfer, SPI_MODE_0}; fn create_spi() -> io::Result<Spidev> { let mut spi = try!(Spidev::open("/dev/spidev0.0")); let options = SpidevOptions::new()...
code_fim
hard
{ "lang": "rust", "repo": "ajiahamed/icefoss", "path": "/code2/session2/mcp3008/src/main2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Perform full duplex operations using Ioctl fn full_duplex(spi: &mut Spidev) -> io::Result<()> { // "write" transfers are also reads at the same time with // the read having the same length as the write let tx_buf = [0x01, 0x80, 0x0]; let mut rx_buf = [0; 3]; { let mut tran...
code_fim
hard
{ "lang": "rust", "repo": "ajiahamed/icefoss", "path": "/code2/session2/mcp3008/src/main2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitchty/src path: /rust/monster.rs trait Monster { fn attack(&self); } struct IndustrialRaverMonkey { strength: int } struct AnnoyingUnixAdmin { strength: int } struct GothKid { strength: int } struct SpittingLlama { strength: int } struct ScreamingChildOnPlane { strengt...
code_fim
hard
{ "lang": "rust", "repo": "mitchty/src", "path": "/rust/monster.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println(fmt!("The llama spit attacks for %d.", self.strength)) } } impl Monster for ScreamingChildOnPlane { fn attack(&self) { println(fmt!("The child next to you on the plane scream attacks for %d.", self.strength)) } } impl Monster for PersonInLineWithCoupons { fn attac...
code_fim
hard
{ "lang": "rust", "repo": "mitchty/src", "path": "/rust/monster.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Monster for ScreamingChildOnPlane { fn attack(&self) { println(fmt!("The child next to you on the plane scream attacks for %d.", self.strength)) } } impl Monster for PersonInLineWithCoupons { fn attack(&self) { println(fmt!("The person in line in front of you uses coupons...
code_fim
hard
{ "lang": "rust", "repo": "mitchty/src", "path": "/rust/monster.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: superoles/rescue_block_cipher path: /rescue-poseidon/src/circuit/sponge.rs use crate::{ common::domain_strategy::DomainStrategy, traits::{HashFamily, HashParams}, }; use franklin_crypto::{ bellman::plonk::better_better_cs::cs::ConstraintSystem, plonk::circuit::allocated_num::Num, }; ...
code_fim
hard
{ "lang": "rust", "repo": "superoles/rescue_block_cipher", "path": "/rescue-poseidon/src/circuit/sponge.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // here we can absorb values. run round function implicitly there absorb::<_, _, P, RATE, WIDTH>(cs, &mut self.state, &mut unwrapped_buffer, params)?; // absorb value buf[0] = Some(input); } SpongeMode::Squeeze(_) => ...
code_fim
hard
{ "lang": "rust", "repo": "superoles/rescue_block_cipher", "path": "/rescue-poseidon/src/circuit/sponge.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: techgeek1/rmath path: /src/clamp.rs pub trait Clamp { fn clamp(self, min: Self, max: Self) -> Self; } impl Clamp for f32 { fn clamp(self, min: f32, max: f32) -> f32 { if self < min { return min; } <|fim_suffix|>pub trait Clamp01 { fn clamp01(self) -> Se...
code_fim
medium
{ "lang": "rust", "repo": "techgeek1/rmath", "path": "/src/clamp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Clamp01 { fn clamp01(self) -> Self; } impl Clamp01 for f32 { fn clamp01(self) -> f32 { if self < 0.0 { return 0.0; } if self > 1.0 { return 1.0; } self } }<|fim_prefix|>// repo: techgeek1/rmath path: /src/clamp.rs p...
code_fim
medium
{ "lang": "rust", "repo": "techgeek1/rmath", "path": "/src/clamp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_response( mut sock: &Connection, tport: Transport, scratch: &mut [u8], ) -> io::Result<usize> { match tport { Transport::Udp => (), _ => assert!(false), } let len = sock.read(&mut scratch[..])?; if len == ...
code_fim
hard
{ "lang": "rust", "repo": "bitslab/CompilerInterrupts", "path": "/benchmarks/shenango/shenango/apps/synthetic/src/dns.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bitslab/CompilerInterrupts path: /benchmarks/shenango/shenango/apps/synthetic/src/dns.rs use Connection; use Packet; use Transport; use byteorder::{BigEndian, WriteBytesExt}; use dns_parser::{Header, Opcode, QueryClass, QueryType, ResponseCode}; use std::io; use std::io::{Error, ErrorKind, Rea...
code_fim
hard
{ "lang": "rust", "repo": "bitslab/CompilerInterrupts", "path": "/benchmarks/shenango/shenango/apps/synthetic/src/dns.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thespaceprincess/turbo path: /turbosql_examples/src/main.rs use turbosql::{select, Blob, Turbosql}; #[derive(Turbosql, Debug, Default)] struct Person { rowid: Option<i64>, // rowid member required & enforced at compile time name: Option<String>, age: Option<i64>, image_jpg: Option<Blob>, } ...
code_fim
hard
{ "lang": "rust", "repo": "thespaceprincess/turbo", "path": "/turbosql_examples/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// // SELECT multiple rows with a predicate // let people: Vec<Person> = select!(Vec<Person> "WHERE age > ?", 21)?; // // SELECT a single row with a predicate // let person: Person = select!(Person "WHERE name = ?", "Joe")?; // // UPDATE single row -- call update() with rowid: Some(i64) // let mut perso...
code_fim
hard
{ "lang": "rust", "repo": "thespaceprincess/turbo", "path": "/turbosql_examples/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// // SELECT a single row with a predicate // let person: Person = select!(Person "WHERE name = ?", "Joe")?; // // UPDATE single row -- call update() with rowid: Some(i64) // let mut person = select!(Person "WHERE name = ?", "Joe")?; // person.age = 18; // person.update()?; // // UPSERT batch // let pe...
code_fim
hard
{ "lang": "rust", "repo": "thespaceprincess/turbo", "path": "/turbosql_examples/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mutex = Mutex::new(5); { let mut num = mutex.lock().unwrap(); *num = 6; } println!("m = {:?}", mutex); }<|fim_prefix|>// repo: HodongMan/rust-thread-prac path: /src/thread/mutex.rs use std::sync::Mutex; <|fim_middle|>fn mutexFunc() {
code_fim
easy
{ "lang": "rust", "repo": "HodongMan/rust-thread-prac", "path": "/src/thread/mutex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HodongMan/rust-thread-prac path: /src/thread/mutex.rs use std::sync::Mutex; fn mutexFunc() { <|fim_suffix|> println!("m = {:?}", mutex); }<|fim_middle|> let mutex = Mutex::new(5); { let mut num = mutex.lock().unwrap(); *num = 6; }
code_fim
medium
{ "lang": "rust", "repo": "HodongMan/rust-thread-prac", "path": "/src/thread/mutex.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("m = {:?}", mutex); }<|fim_prefix|>// repo: HodongMan/rust-thread-prac path: /src/thread/mutex.rs use std::sync::Mutex; fn mutexFunc() { <|fim_middle|> let mutex = Mutex::new(5); { let mut num = mutex.lock().unwrap(); *num = 6; }
code_fim
medium
{ "lang": "rust", "repo": "HodongMan/rust-thread-prac", "path": "/src/thread/mutex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let vec: Vec<i32> = (0..1000000).collect(); vec[..].into() }<|fim_prefix|>// repo: qthree/stdweb_TypedArray_leak path: /src/lib.rs #![feature(proc_macro)] #[macro_use] extern crate stdweb; use stdweb::js_export; use stdweb::web::TypedArray; <|fim_middle|>#[js_export] fn data() -> TypedArray<i3...
code_fim
easy
{ "lang": "rust", "repo": "qthree/stdweb_TypedArray_leak", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qthree/stdweb_TypedArray_leak path: /src/lib.rs #![feature(proc_macro)] <|fim_suffix|>use stdweb::js_export; use stdweb::web::TypedArray; #[js_export] fn data() -> TypedArray<i32> { let vec: Vec<i32> = (0..1000000).collect(); vec[..].into() }<|fim_middle|>#[macro_use] extern crate stdw...
code_fim
easy
{ "lang": "rust", "repo": "qthree/stdweb_TypedArray_leak", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VulkanWorks/korangar path: /src/loaders/map/resource.rs #[derive(Copy, Clone, Debug)] pub enum ResourceType { Object, LightSource, SoundSource, EffectSource } <|fim_suffix|> pub fn from(index: i32) -> Self { match index { 1 => return ResourceType::Object, ...
code_fim
easy
{ "lang": "rust", "repo": "VulkanWorks/korangar", "path": "/src/loaders/map/resource.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from(index: i32) -> Self { match index { 1 => return ResourceType::Object, 2 => return ResourceType::LightSource, 3 => return ResourceType::SoundSource, 4 => return ResourceType::EffectSource, invalid => panic!("invalid object ...
code_fim
easy
{ "lang": "rust", "repo": "VulkanWorks/korangar", "path": "/src/loaders/map/resource.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hamadakafu/kyopro path: /src/bin/abc150c.rs use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; fn main() { <|fim_suffix|> let mut a = 0; let mut b = 0; for (i, num) in (1..=n as u64).into_iter().permutations(n).en...
code_fim
medium
{ "lang": "rust", "repo": "hamadakafu/kyopro", "path": "/src/bin/abc150c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let n: usize = parse_line().unwrap(); let pp: Vec<u64> = parse_line().unwrap(); let qq: Vec<u64> = parse_line().unwrap(); let mut a = 0; let mut b = 0; for (i, num) in (1..=n as u64).into_iter().permutations(n).enumerate() { if pp == num { a = i as i64 + 1; ...
code_fim
medium
{ "lang": "rust", "repo": "hamadakafu/kyopro", "path": "/src/bin/abc150c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = 0; let mut b = 0; for (i, num) in (1..=n as u64).into_iter().permutations(n).enumerate() { if pp == num { a = i as i64 + 1; } if qq == num { b = i as i64 + 1; } } println!("{}", (a - b).abs()); }<|fim_prefix|>// repo: ...
code_fim
medium
{ "lang": "rust", "repo": "hamadakafu/kyopro", "path": "/src/bin/abc150c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_seq_num_max(&self) -> Option<SequenceNumber>; fn iter(&self) -> Iter<CacheChange>; }<|fim_prefix|>// repo: BillBarnhill/rtps path: /src/entity/traits/history_cache_trait.rs use super::super::super::common_types::*; use std::slice::Iter; pub type ErrorStr = &'static str; pub type HistoryCa...
code_fim
hard
{ "lang": "rust", "repo": "BillBarnhill/rtps", "path": "/src/entity/traits/history_cache_trait.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BillBarnhill/rtps path: /src/entity/traits/history_cache_trait.rs use super::super::super::common_types::*; use std::slice::Iter; pub type ErrorStr = &'static str; pub type HistoryCacheResult = Result<(),ErrorStr>; pub trait HistoryCacheTrait where Self: Sized { fn new() -> Self; <|fim_suf...
code_fim
hard
{ "lang": "rust", "repo": "BillBarnhill/rtps", "path": "/src/entity/traits/history_cache_trait.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: highpear/rust-tutorial-yt path: /09_tuples/main.rs fn main() { let tup1 = (20, "Rust", true); let (a, b, c) = tup1; <|fim_suffix|>b: {}", b); println!("c: {}", c); }<|fim_middle|> println!("a: {}", a); println!("
code_fim
easy
{ "lang": "rust", "repo": "highpear/rust-tutorial-yt", "path": "/09_tuples/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("a: {}", a); println!("b: {}", b); println!("c: {}", c); }<|fim_prefix|>// repo: highpear/rust-tutorial-yt path: /09_tuples/main.rs fn main() { let tup1 = (20, "Rust<|fim_middle|>", true); let (a, b, c) = tup1;
code_fim
easy
{ "lang": "rust", "repo": "highpear/rust-tutorial-yt", "path": "/09_tuples/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>b: {}", b); println!("c: {}", c); }<|fim_prefix|>// repo: highpear/rust-tutorial-yt path: /09_tuples/main.rs fn main() { let tup1 = (20, "Rust<|fim_middle|>", true); let (a, b, c) = tup1; println!("a: {}", a); println!("
code_fim
medium
{ "lang": "rust", "repo": "highpear/rust-tutorial-yt", "path": "/09_tuples/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LinkTed/dbus-message-parser path: /src/match_rule/encode.rs use super::MatchRule; use std::fmt::{Display, Formatter, Result as FmtResult}; impl Display for MatchRule { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { match self { MatchRule::Type(r#type) => write!(f, "...
code_fim
hard
{ "lang": "rust", "repo": "LinkTed/dbus-message-parser", "path": "/src/match_rule/encode.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> } impl MatchRule { pub fn encode(match_rules: &[MatchRule]) -> String { let mut iter = match_rules.iter(); if let Some(match_rule) = iter.next() { let mut result = match_rule.to_string(); for match_rule in iter { result.push(','); ...
code_fim
hard
{ "lang": "rust", "repo": "LinkTed/dbus-message-parser", "path": "/src/match_rule/encode.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coastalwhite/WasmSVGGraphics path: /tests/web.rs wasm_bindgen_test::*; wasm_bindgen_test_configure!(run_in_browser); fn get_document() -> web_sys::Document { let window = web_sys::window().expect("Cant find window"); window.document().expect("Cant find Document") } fn add_svg_parent...
code_fim
hard
{ "lang": "rust", "repo": "coastalwhite/WasmSVGGraphics", "path": "/tests/web.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coastalwhite/WasmSVGGraphics path: /tests/web.rs nt() { let prev_parent = get_document().get_element_by_id("svg_parent_id"); match prev_parent { Some(el) => { el.set_inner_html(""); } None => { let parent = get_document() ....
code_fim
hard
{ "lang": "rust", "repo": "coastalwhite/WasmSVGGraphics", "path": "/tests/web.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use wasm_svg_graphics::prelude::*; // Declare renderer (must be mutable) let mut renderer = SVGRenderer::new("svg_parent_id").expect("Failed to create renderer!"); // Adds the named container 'named_container' to the svg root renderer.create_named_container("named_container", "root")...
code_fim
hard
{ "lang": "rust", "repo": "coastalwhite/WasmSVGGraphics", "path": "/tests/web.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> addstr("Here is what you typed: \n"); getnstr(&mut buffer, CAPACITY as i32); refresh(); getch(); endwin(); }<|fim_prefix|>// repo: smart--petea/ncurses_book_rust path: /l7_4/src/main.rs extern crate ncurses; use ncurses::*; <|fim_middle|>fn main() { const CAPACITY: usize = 81; ...
code_fim
hard
{ "lang": "rust", "repo": "smart--petea/ncurses_book_rust", "path": "/l7_4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smart--petea/ncurses_book_rust path: /l7_4/src/main.rs extern crate ncurses; use ncurses::*; <|fim_suffix|> const CAPACITY: usize = 81; let mut buffer: String = String::with_capacity(CAPACITY); initscr(); addstr("Type on the keyboard whilst I wait...\n"); refresh(); nap...
code_fim
easy
{ "lang": "rust", "repo": "smart--petea/ncurses_book_rust", "path": "/l7_4/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> addstr("Type on the keyboard whilst I wait...\n"); refresh(); napms(5000); addstr("Here is what you typed: \n"); getnstr(&mut buffer, CAPACITY as i32); refresh(); getch(); endwin(); }<|fim_prefix|>// repo: smart--petea/ncurses_book_rust path: /l7_4/src/main.rs extern cra...
code_fim
medium
{ "lang": "rust", "repo": "smart--petea/ncurses_book_rust", "path": "/l7_4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let source = "010|00b|000"; let boundary = Boundary::from_str(source).unwrap(); println!("Built boundary:\n{:?}", boundary); } #[test] fn build_succeeds_different_boundary() { let source = "010?001%010"; let boundary = Boundary::from_str(source).unwrap(); assert!(boundary.requir...
code_fim
hard
{ "lang": "rust", "repo": "phigley/wfc", "path": "/tests/boundary.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phigley/wfc path: /tests/boundary.rs extern crate wfc; use wfc::boundary::{Boundary, Direction}; #[test] fn build_from_str_north() { let source = "010|000|000"; let boundary = Boundary::from_str(source).unwrap(); assert!(boundary.requires(Direction::North)); assert!(!boundary....
code_fim
hard
{ "lang": "rust", "repo": "phigley/wfc", "path": "/tests/boundary.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tinans7/cargo-wsinit path: /wsinit/tests/workspace_search_update_tests.rs mod test_utils; #[cfg(test)] mod tests { use std::fs::{self, File}; use std::path::{Path, PathBuf}; use cargo_wsinit::*; use crate::test_utils::*; #[test] fn update_paths() { let test_ro...
code_fim
hard
{ "lang": "rust", "repo": "Tinans7/cargo-wsinit", "path": "/wsinit/tests/workspace_search_update_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let file_contents = read_file(&toml_file); assert_eq!( "[workspace]\n\nmembers = [\n \"lib1\",\n \"lib2\",\n]\n", file_contents ); } fn make_lib(path: &Path, lib_name: &str) { let path = create_path(path, lib_name); let toml ...
code_fim
hard
{ "lang": "rust", "repo": "Tinans7/cargo-wsinit", "path": "/wsinit/tests/workspace_search_update_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/indexa path: /src/bin/ix/tui/table.rs // The MIT License (MIT) // // Copyright (c) 2016 Florian Dehau // Copyright (c) 2020 mosm // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/indexa", "path": "/src/bin/ix/tui/table.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (c, (w, &&alignment, elt)) in izip!(solved_widths.iter(), alignments.iter(), row.data).enumerate() { let width = if c == 0 { *w - symbol.width() as u16 } else { *...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/indexa", "path": "/src/bin/ix/tui/table.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(dead_code)] pub fn column_spacing(mut self, spacing: u16) -> Table<'a, H, R, F> { self.column_spacing = spacing; self } #[allow(dead_code)] pub fn header_gap(mut self, gap: u16) -> Table<'a, H, R, F> { self.header_gap = gap; self } } impl<'...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/indexa", "path": "/src/bin/ix/tui/table.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khalid-salad/Computer-Networks-Project path: /protobuf/udp/rust/client/src/main.rs use std::env; use std::net::UdpSocket; mod person; use protobuf::Message; fn main() -> std::io::Result<()> { let args: Vec<String> = env::args().collect(); let host = &args[1]; let port = &args[2]; ...
code_fim
hard
{ "lang": "rust", "repo": "khalid-salad/Computer-Networks-Project", "path": "/protobuf/udp/rust/client/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>se_from_bytes(&buffer[..length])?; println!("Received message from server."); println!("name: {}", server.get_name()); println!("id: {}", server.get_id()); Ok(()) } // the stream is closed here<|fim_prefix|>// repo: khalid-salad/Computer-Networks-Project path: /protobuf/udp/rust/client/sr...
code_fim
hard
{ "lang": "rust", "repo": "khalid-salad/Computer-Networks-Project", "path": "/protobuf/udp/rust/client/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-bakery/nom path: /src/branch/tests.rs use crate::branch::{alt, permutation}; use crate::bytes::streaming::tag; use crate::error::ErrorKind; use crate::internal::{Err, IResult, Needed}; use crate::Parser; #[cfg(feature = "alloc")] use crate::{ error::ParseError, lib::std::{ fmt::Debu...
code_fim
hard
{ "lang": "rust", "repo": "rust-bakery/nom", "path": "/src/branch/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let a = &b"abcdefghijk"[..]; assert_eq!(perm(a), Ok((&b"jk"[..], expected))); let b = &b"efgabcdhijk"[..]; assert_eq!(perm(b), Ok((&b"jk"[..], expected))); let c = &b"hiefgabcdjk"[..]; assert_eq!(perm(c), Ok((&b"jk"[..], expected))); let d = &b"efgxyzabcdefghi"[..]; assert_eq!( perm(d...
code_fim
hard
{ "lang": "rust", "repo": "rust-bakery/nom", "path": "/src/branch/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd11c14a/src/tc1/count32/evctrl.rs #[doc = "Reader of register EVCTRL"] pub type R = crate::R<u16, super::EVCTRL>; #[doc = "Writer for register EVCTRL"] pub type W = crate::W<u16, super::EVCTRL>; #[doc = "Register EVCTRL `reset()`'s with value 0"] impl crate::ResetV...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsamd11c14a/src/tc1/count32/evctrl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>; self.w } } #[doc = "Reader of field `TCEI`"] pub type TCEI_R = crate::R<bool, bool>; #[doc = "Write proxy for field `TCEI`"] pub struct TCEI_W<'a> { w: &'a mut W, } impl<'a> TCEI_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { ...
code_fim
hard
{ "lang": "rust", "repo": "wgwoods/atsamd", "path": "/pac/atsamd11c14a/src/tc1/count32/evctrl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut str = String::new(); io::stdin().read_line(&mut str).unwrap(); str = str.trim().to_uppercase(); return match str.as_ref() { "Y" => true, "YES" => true, _ => false, }; } fn main() { println!("{}", White.bg(White).bold().paint(" ")); ...
code_fim
hard
{ "lang": "rust", "repo": "kapitanov/rust-guess-game", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kapitanov/rust-guess-game path: /src/main.rs use rand::Rng; use std::cmp::Ordering; use std::io; use std::io::Write; use term_painter::Color::*; use term_painter::ToStyle; fn read_guess() -> u32 { let mut str = String::new(); loop { print!("Enter your guess: "); io::stdo...
code_fim
hard
{ "lang": "rust", "repo": "kapitanov/rust-guess-game", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/easy/distribute_candies.rs // https://leetcode.com/problems/distribute-candies/ use std::collections::HashSet; <|fim_suffix|> let mut ans = s.len(); if ans > candies.len() / 2 { ans = candies.len() / 2; } ans as i...
code_fim
medium
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/easy/distribute_candies.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut ans = s.len(); if ans > candies.len() / 2 { ans = candies.len() / 2; } ans as i32 } }<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/easy/distribute_candies.rs // https://leetcode.com/problems/distribute-candies/ use std::collections::...
code_fim
medium
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/easy/distribute_candies.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }