text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let days_in_cur_year = days_in_year(year); if ordinal > days_in_cur_year { Self::from_yo_unchecked(year + 1, ordinal - days_in_cur_year) } else { Self::from_yo_unchecked(year, ordinal) } } pub(crate) fn from_ymd_unchecked(year: i32, month: u...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/time-macros-impl/src/time_crate/date.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/time-macros-impl/src/time_crate/date.rs use super::Weekday::{self, Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday}; #[allow(unused_imports)] use standback::prelude::*; fn is_leap_year(year: i32) -> bool { (year % 4 == 0) && ((year % 100...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/time-macros-impl/src/time_crate/date.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szymonwieloch/rust-dlopen path: /src/err.rs use std::error::Error as ErrorTrait; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::convert::From; use std::ffi::NulError; use std::io::Error as IoError; ///This is a library-specific error that is returned by all calls to all APIs....
code_fim
medium
{ "lang": "rust", "repo": "szymonwieloch/rust-dlopen", "path": "/src/err.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use self::Error::*; match self { &NullCharacter(_) => write!(f, "String had a null character"), &OpeningLibraryError(ref msg) => write!(f, "Could not open library: {}", msg), &SymbolGettingError(ref msg) => write!(f, "Could not obtain symbol from the lib...
code_fim
hard
{ "lang": "rust", "repo": "szymonwieloch/rust-dlopen", "path": "/src/err.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Check `rposition().is_none()`, single-line case. let _ = v.iter().rposition(|&x| x < 0).is_none(); let s1 = String::from("hello world"); let s2 = String::from("world"); // caller of `find()` is a `&`static str` let _ = "hello world".find("world").is_none(); let _ = "hello ...
code_fim
hard
{ "lang": "rust", "repo": "rust9x/rust", "path": "/src/tools/clippy/tests/ui/search_is_some_fixable.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust9x/rust path: /src/tools/clippy/tests/ui/search_is_some_fixable.rs // run-rustfix #![allow(dead_code)] #![warn(clippy::search_is_some)] fn main() { let v = vec![3, 2, 1, 0, -1, -2, -3]; let y = &&42; // Check `find().is_some()`, single-line case. let _ = v.iter().find(|&x| ...
code_fim
hard
{ "lang": "rust", "repo": "rust9x/rust", "path": "/src/tools/clippy/tests/ui/search_is_some_fixable.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Check `position().is_none()`, single-line case. let _ = v.iter().position(|&x| x < 0).is_none(); // Check `rposition().is_none()`, single-line case. let _ = v.iter().rposition(|&x| x < 0).is_none(); let s1 = String::from("hello world"); let s2 = String::from("world"); // ...
code_fim
hard
{ "lang": "rust", "repo": "rust9x/rust", "path": "/src/tools/clippy/tests/ui/search_is_some_fixable.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghcom275/duplex path: /src/lib.rs //! The `Duplex` trait: interactive streams <|fim_suffix|>#[cfg(feature = "futures-io")] pub use crate::duplex::FullDuplex; #[cfg(feature = "tokio")] pub use crate::duplex::TokioFullDuplex; pub use crate::duplex::{Duplex, HalfDuplex};<|fim_middle|>#![deny(missi...
code_fim
medium
{ "lang": "rust", "repo": "ghcom275/duplex", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghcom275/duplex path: /src/lib.rs //! The `Duplex` trait: interactive streams <|fim_suffix|>mod duplex; #[cfg(feature = "futures-io")] pub use crate::duplex::FullDuplex; #[cfg(feature = "tokio")] pub use crate::duplex::TokioFullDuplex; pub use crate::duplex::{Duplex, HalfDuplex};<|fim_middle|>...
code_fim
easy
{ "lang": "rust", "repo": "ghcom275/duplex", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "futures-io")] pub use crate::duplex::FullDuplex; #[cfg(feature = "tokio")] pub use crate::duplex::TokioFullDuplex; pub use crate::duplex::{Duplex, HalfDuplex};<|fim_prefix|>// repo: ghcom275/duplex path: /src/lib.rs //! The `Duplex` trait: interactive streams #![deny(missing_docs)] #![f...
code_fim
easy
{ "lang": "rust", "repo": "ghcom275/duplex", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bmancini55/rust-playpen path: /rustbook/ch09-02-errors/src/main.rs use std::fs::File; use std::io; use std::io::ErrorKind; use std::io::Read; fn main() { // Result<T, E> will return either the value or an error. We can use a match // expression to determine what the result was and casca...
code_fim
hard
{ "lang": "rust", "repo": "bmancini55/rust-playpen", "path": "/rustbook/ch09-02-errors/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match f.read_to_string(&mut s) { Ok(_) => Ok(s), Err(e) => Err(e), } } /// This version does the same as above but uses the ? operator to propagate the /// error up the call stack. fn read_file_contents_shorter() -> Result<String, io::Error> { let mut f = File::open("hello.txt...
code_fim
medium
{ "lang": "rust", "repo": "bmancini55/rust-playpen", "path": "/rustbook/ch09-02-errors/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cactorium/blosh path: /src/lib.rs #[macro_use] extern crate nom; // data link level parsers pub mod ethernet; // internet level parsers pub mod ipv4; pub mod ipv6; // transport level parsers pub mod tcp; pub mod udp; // application level parsers pub mod dns; // pub mod smtp; #[derive(Clone,...
code_fim
hard
{ "lang": "rust", "repo": "cactorium/blosh", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let packet = [ 0x00, 0x50, 0x56, 0xbb, 0x3a, 0xa0, 0x00, 0x1f, 0x29, 0x5e, 0x4d, 0x26, 0x08, 0x00, 0x45, 0x00, 0x00, 0xdb, 0x51, 0x4e, 0x00, 0x00, 0x31, 0x06, 0x95, 0x48, 0x4a, 0x7d, 0x83, 0x1b, 0xc0, 0xa8, 0x14, 0x46, 0x00, 0x19, 0xd5, ...
code_fim
hard
{ "lang": "rust", "repo": "cactorium/blosh", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thealexhoar/radium path: /src/util/clargs.rs use std::env; pub fn collect() -> Vec<String> { let mut out = Vec::new();<|fim_suffix|> out.push(argument); } out }<|fim_middle|> for argument in env::args() {
code_fim
easy
{ "lang": "rust", "repo": "thealexhoar/radium", "path": "/src/util/clargs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> out.push(argument); } out }<|fim_prefix|>// repo: thealexhoar/radium path: /src/util/clargs.rs use std::env; pub fn collect() -> Vec<<|fim_middle|>String> { let mut out = Vec::new(); for argument in env::args() {
code_fim
medium
{ "lang": "rust", "repo": "thealexhoar/radium", "path": "/src/util/clargs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let host = match parts_iter.next() { Some(s) => s, None => { return Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid socket address")) } }; let port: u16 = match port_str.parse() { Ok(p) => p, Err(...
code_fim
hard
{ "lang": "rust", "repo": "pgerber/rust-socks", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(addr) = self.parse::<SocketAddrV6>() { return addr.to_target_addr(); } // split the string by ':' and convert the second part to u16 let mut parts_iter = self.rsplitn(2, ':'); let port_str = match parts_iter.next() { Some(s) => s, ...
code_fim
hard
{ "lang": "rust", "repo": "pgerber/rust-socks", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pgerber/rust-socks path: /src/lib.rs //! SOCKS proxy clients #![doc(html_root_url="https://docs.rs/socks/0.3.0")] #![warn(missing_docs)] extern crate byteorder; #[cfg(unix)] extern crate libc; #[cfg(windows)] extern crate winapi; #[cfg(windows)] extern crate ws2_32; use std::io; use std::net:...
code_fim
hard
{ "lang": "rust", "repo": "pgerber/rust-socks", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> HyperServer::new( App::<HyperRequest, Ctx, ()>::create(generate_context, ()).post("/json", m![echo_json]), ) .build("0.0.0.0", 4321) .await; }<|fim_prefix|>// repo: thruster-rs/Thruster path: /thruster/examples/json.rs use log::info; use serde::{Deserialize, Serialize}; use thrust...
code_fim
hard
{ "lang": "rust", "repo": "thruster-rs/Thruster", "path": "/thruster/examples/json.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thruster-rs/Thruster path: /thruster/examples/json.rs use log::info; use serde::{Deserialize, Serialize}; use thruster::{ context::{ basic_hyper_context::{generate_context, BasicHyperContext as Ctx, HyperRequest}, context_ext::ContextExt, }, errors::ThrusterError, ...
code_fim
medium
{ "lang": "rust", "repo": "thruster-rs/Thruster", "path": "/thruster/examples/json.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use std::io::Write; // TODO: allow shutting this writing to tempfile business off and using ram only for eg python where this is possible // TODO: allow specifying which directory to use for tempfiles // TODO: manage deletion of tempfiles better - to start with, do it at all, eg after succ...
code_fim
medium
{ "lang": "rust", "repo": "lahwran/milkshell", "path": "/src/launch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!( "running: {:?} {:?} {:?} {:?} {:?} {:?}", PYTHON_BIN, filename, cmd, previous_connector, next_connector, debug_connector ); // TODO: open fds 3:w,4:r,5:w,6:r as pipes, like one normally would with fds 0:w,1:r,2:r Co...
code_fim
hard
{ "lang": "rust", "repo": "lahwran/milkshell", "path": "/src/launch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lahwran/milkshell path: /src/launch.rs use crate::codegen::codegen; use crate::parse::SharedInvocation; use futures::future::join_all; use std::fs; use std::fs::File; use std::path::Path; use tokio; use tokio::process::Command; const PYTHON_BIN: &'static str = "/Users/lahwran/milkshell/python/....
code_fim
medium
{ "lang": "rust", "repo": "lahwran/milkshell", "path": "/src/launch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gz/rust-dpdk path: /src/mempool.rs // rte_mempool.h extern crate libc; use std::os::raw::c_void; use ffi; use lcore; pub unsafe fn get_ops(ops_index: usize) -> *const ffi::rte_mempool_ops { &ffi::rte_mempool_ops_table.ops[ops_index] } pub unsafe fn ops_enqueue_bulk(mp: *mut ffi::rte_mempo...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-dpdk", "path": "/src/mempool.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn put_bulk(mp: *mut ffi::rte_mempool, obj_table: &[*mut c_void]) { let cache = default_cache(mp, lcore::id()); generic_put(mp, obj_table, cache); } pub unsafe fn put(mp: *mut ffi::rte_mempool, obj: *mut c_void) { let obj_table: [*mut c_void; 1] = [obj]; put_bulk(mp, &obj_tabl...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-dpdk", "path": "/src/mempool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn default_cache( mp: *mut ffi::rte_mempool, lcore_id: u32, ) -> *mut ffi::rte_mempool_cache { (*mp).local_cache.offset(lcore_id as isize) } pub unsafe fn put_bulk(mp: *mut ffi::rte_mempool, obj_table: &[*mut c_void]) { let cache = default_cache(mp, lcore::id()); generic_pu...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-dpdk", "path": "/src/mempool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmfink/yinetd path: /src/config/parse/mod.rs // pest creates enums in all-caps #![allow(clippy::upper_case_acronyms)] #[cfg(test)] mod test; use std::{ fs::{self, File}, io::{prelude::*, BufReader}, path::Path, }; use log::trace; use pest::Parser; use pest_derive::Parser; use cra...
code_fim
hard
{ "lang": "rust", "repo": "tmfink/yinetd", "path": "/src/config/parse/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let body_pair = pair_inner.next().unwrap(); service_option.update_from_body_pair(body_pair)?; service_option.fill_with_defaults(&default_options); let service = Service::from_optioned(service_option, service_name, &pair)?; co...
code_fim
hard
{ "lang": "rust", "repo": "tmfink/yinetd", "path": "/src/config/parse/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: selcuk-arslan/rust_opencv_face_detection path: /src/main.rs extern crate opencv; use std::*; use opencv::{ core, imgproc, objdetect, prelude::*, types }; fn get_faces(frame: &opencv::prelude::Mat) -> opencv::Result<types::VectorOfRect> { let mut gray = Mat::default()?;...
code_fim
hard
{ "lang": "rust", "repo": "selcuk-arslan/rust_opencv_face_detection", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut params: core::Vector<i32> = core::Vector::new(); opencv::imgcodecs::imwrite("./data/output.jpg", &frame, &mut params)?; return Ok(()) } fn main() { run().unwrap() }<|fim_prefix|>// repo: selcuk-arslan/rust_opencv_face_detection path: /src/main.rs extern crate opencv; use std::*...
code_fim
hard
{ "lang": "rust", "repo": "selcuk-arslan/rust_opencv_face_detection", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("faces: {}", faces.len()); for face in faces { println!("face {:?}", face); imgproc::rectangle(&mut frame, face, core::Scalar::new(0f64, 0f64, 255f64, 0f64), 3, 8, 0)?; } let mut params: core::Vector<i32> = core::Vector::new(); opencv::imgcodecs::imwrite("./da...
code_fim
hard
{ "lang": "rust", "repo": "selcuk-arslan/rust_opencv_face_detection", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/dom/qualified_name.rs use std::fmt; use crate::console::{Argument, ToArgument}; pub use arwa_parse::xml_name::InvalidQualifiedName; #[doc(hidden)] #[derive(Clone)] pub struct StaticallyParsedQualifiedName { #[doc(hidden)] pub name: &'static str, #[d...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/ARWA", "path": "/arwa/src/dom/qualified_name.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl PartialEq<QualifiedName> for &'_ str { #[inline] fn eq(&self, other: &QualifiedName) -> bool { other == self } } impl fmt::Display for QualifiedName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let as_str: &str = self.as_ref(); fmt::Display::f...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/ARWA", "path": "/arwa/src/dom/qualified_name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Property { fn as_write_byte(self) -> u8 { use Property::*; match self { Color => 0xB2, Dpi => 0x96, PollingRate => 0x83, Distance => 0xB8, } } fn as_read_byte(self) -> u8 { if self == Property::Distance { ...
code_fim
hard
{ "lang": "rust", "repo": "tarkah/pro-intellimouse-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self == Property::Distance { self.as_write_byte() - 2 } else { self.as_write_byte() + 1 } } } #[derive(Debug)] pub enum PropertyValue { Color(u32), Distance(Distance), Dpi(u32), PollingRate(PollingRate), } #[derive(Debug)] pub enum P...
code_fim
hard
{ "lang": "rust", "repo": "tarkah/pro-intellimouse-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarkah/pro-intellimouse-rs path: /src/lib.rs use byteorder::{BigEndian, ByteOrder, LittleEndian}; use hidapi::HidDevice; use log::info; const VID: u16 = 0x045E; const PID: u16 = 0x082A; const WRITE_REPORT_ID: u8 = 0x24; const WRITE_REPORT_LEN: usize = 73; const READ_REPORT_ID: u8 = 0x27; const ...
code_fim
hard
{ "lang": "rust", "repo": "tarkah/pro-intellimouse-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args = env::args().collect::<Vec<_>>(); let addr = &args[1]; let num = args[2].to_string().parse().unwrap(); let env = Arc::new(EnvBuilder::new().build()); let ch = ChannelBuilder::new(env) .stream_initial_window_size(20 * 1024 * 1024) .keepalive_time(time::Duration...
code_fim
medium
{ "lang": "rust", "repo": "shafreeck/grpcstream", "path": "/src/client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shafreeck/grpcstream path: /src/client.rs mod protos; use std::env; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::thread; use std::time; use std::vec::Vec; use futures::{Future, Sink}; use grpcio::{ChannelBuilder, EnvBuilder, WriteFlags}; <|fim_suffix|>fn main() {...
code_fim
medium
{ "lang": "rust", "repo": "shafreeck/grpcstream", "path": "/src/client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: halvko/roche path: /examples/full/src/lib.rs #[cfg(test)] mod tests { #[async_std::test] async fn it_works() { let uri = "http://localhost:8080/"; let string: String = match surf::get(uri).<|fim_suffix|>string() }; assert!(string.contains("httpbin...
code_fim
medium
{ "lang": "rust", "repo": "halvko/roche", "path": "/examples/full/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>string() }; assert!(string.contains("httpbin.org")); } }<|fim_prefix|>// repo: halvko/roche path: /examples/full/src/lib.rs #[cfg(test)] mod tests { #[async_std::test] async fn it_works() { let uri = "http://localhost:8080/"; let string: String = match...
code_fim
medium
{ "lang": "rust", "repo": "halvko/roche", "path": "/examples/full/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let pool_vrf: KeyPair<Curve25519_2HashDH> = KeyPair::generate(&mut rng); let pool_kes: KeyPair<SumEd25519_12> = KeyPair::generate(&mut rng); let pool_info = PoolRegistration { serial: 1234, owners: self.owners.iter().cloned().collect(), start_va...
code_fim
hard
{ "lang": "rust", "repo": "SebastienGllmt/chain-libs", "path": "/chain-impl-mockchain/src/testing/builders/stake_pool_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SebastienGllmt/chain-libs path: /chain-impl-mockchain/src/testing/builders/stake_pool_builder.rs use crate::{ certificate::PoolRegistration, leadership::genesis::GenesisPraosLeader, rewards::TaxType, testing::data::StakePool, }; use chain_crypto::{Curve25519_2HashDH, Ed25519, KeyPair, Pu...
code_fim
medium
{ "lang": "rust", "repo": "SebastienGllmt/chain-libs", "path": "/chain-impl-mockchain/src/testing/builders/stake_pool_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn build(&self) -> StakePool { let mut rng = rand_os::OsRng::new().unwrap(); let pool_vrf: KeyPair<Curve25519_2HashDH> = KeyPair::generate(&mut rng); let pool_kes: KeyPair<SumEd25519_12> = KeyPair::generate(&mut rng); let pool_info = PoolRegistration { ...
code_fim
medium
{ "lang": "rust", "repo": "SebastienGllmt/chain-libs", "path": "/chain-impl-mockchain/src/testing/builders/stake_pool_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if data.len() > 0 { //1000 { // need to see if there is a better way to figure out when to do aggregation req_data .lamellae .send_to_pes(req_data.pe, team.arch.clone(), data); if req_data.pe == None && my_pe != None { ...
code_fim
hard
{ "lang": "rust", "repo": "JosephCottam/lamellar-runtime", "path": "/src/active_messaging/registered_active_message.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JosephCottam/lamellar-runtime path: /src/active_messaging/registered_active_message.rs use crate::active_messaging::{ ActiveMessageEngine, Cmd, ExecType, LamellarAny, LamellarBoxedAm, LamellarReturn, Msg, RetType, REQUESTS, }; use crate::lamellae::LamellaeAM; use crate::lamellar_request:...
code_fim
hard
{ "lang": "rust", "repo": "JosephCottam/lamellar-runtime", "path": "/src/active_messaging/registered_active_message.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgoodlad/rtl8710-pac path: /src/syscon/slp_wake_event_status0.rs elf) -> bool { self.bits } #[doc = r" Returns `true` if the bit is clear (0)"] #[inline] pub fn bit_is_clear(&self) -> bool { !self.bit() } #[doc = r" Returns `true` if the bit is set (1)"] ...
code_fim
hard
{ "lang": "rust", "repo": "dgoodlad/rtl8710-pac", "path": "/src/syscon/slp_wake_event_status0.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgoodlad/rtl8710-pac path: /src/syscon/slp_wake_event_status0.rs } #[doc = r" Returns `true` if the bit is set (1)"] #[inline] pub fn bit_is_set(&self) -> bool { self.bit() } } #[doc = r" Value of the field"] pub struct SYSON_WEVT_SYSTIM_STSR { bits: bool, } impl S...
code_fim
hard
{ "lang": "rust", "repo": "dgoodlad/rtl8710-pac", "path": "/src/syscon/slp_wake_event_status0.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>0; self.w.bits &= !((MASK as u32) << OFFSET); self.w.bits |= ((value & MASK) as u32) << OFFSET; self.w } } impl R { #[doc = r" Value of the register as raw bits"] #[inline] pub fn bits(&self) -> u32 { self.bits } #[doc = "Bit 29"] #[inline] p...
code_fim
hard
{ "lang": "rust", "repo": "dgoodlad/rtl8710-pac", "path": "/src/syscon/slp_wake_event_status0.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn write_to_buffer( &self, buffer: &mut [u8], _fds: &mut [RawDescriptor], ) -> MsgResult<usize> { if buffer.len() < size_of::<$native_type>() { return Err(MsgError::WrongMsgBufferSize); ...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/msg_socket/src/msg_on_socket.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>where T: Copy, O: Default + AsMut<[T]>, { let mut o = O::default(); let o_slice = o.as_mut(); let len = o_slice.len(); o_slice.copy_from_slice(&s[..len]); o } macro_rules! array_impls { ($N:expr, $t: ident $($ts:ident)*) => { impl<T: MsgOnSocket + Clone> MsgOnS...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/msg_socket/src/msg_on_socket.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgreid/crosvm path: /msg_socket/src/msg_on_socket.rs // Copyright 2018 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. mod slice; mod tuple; use std::fmt::{self, Display}; use std::mem::{size_...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/msg_socket/src/msg_on_socket.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theotherphil/imagecli path: /src/documentation/stack_diagram.rs //! Support for rendering markdown diagrams showing the evolution of the //! image stack as a pipeline is evaluated. use std::fmt::Write; /// A diagram showing the evolution of the image stack /// as a pipeline is evaluated. #[der...
code_fim
hard
{ "lang": "rust", "repo": "theotherphil/imagecli", "path": "/src/documentation/stack_diagram.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl StackDiagram { /// Render the stack in a form suitable for inclusion in a markdown document. pub fn render_for_markdown(&self) -> String { let mut rendered = String::new(); writeln!(rendered, "```").unwrap(); for stage in &self.stages { match stage { ...
code_fim
hard
{ "lang": "rust", "repo": "theotherphil/imagecli", "path": "/src/documentation/stack_diagram.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kennykerr/com-rs path: /examples/aggregation/server/src/windows_file_manager.rs use com::{ interfaces::iunknown::IUnknown, runtime::{create_aggregated_instance, init_runtime}, }; use interface::{ ifile_manager::IFileManager, ilocal_file_manager::ILocalFileManager, CLSID_LOCAL_FI...
code_fim
medium
{ "lang": "rust", "repo": "kennykerr/com-rs", "path": "/examples/aggregation/server/src/windows_file_manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl WindowsFileManager { pub(crate) fn new() -> Box<WindowsFileManager> { let mut wfm = WindowsFileManager::allocate(20); init_runtime().expect("Failed to get runtime!"); let iunknown = create_aggregated_instance::<dyn IUnknown, WindowsFileManager>( &CLSID_LOCAL_FI...
code_fim
hard
{ "lang": "rust", "repo": "kennykerr/com-rs", "path": "/examples/aggregation/server/src/windows_file_manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> HtmlTemplate { filepath, template } } } impl<'a, T> Responder for HtmlTemplate<'a, T> where T: Serialize, { fn respond_to(self, _req: &HttpRequest) -> HttpResponse { let context = match Context::from_serialize(self.template).map_err(|_| TemplateError) { Ok(context)...
code_fim
medium
{ "lang": "rust", "repo": "gaku-sei/zagreus-identity-provider", "path": "/zagreus/src/views/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let context = match Context::from_serialize(self.template).map_err(|_| TemplateError) { Ok(context) => context, Err(_) => return HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR), }; let html_string = match TEMPLATES.render(self.filepath, &context) { ...
code_fim
hard
{ "lang": "rust", "repo": "gaku-sei/zagreus-identity-provider", "path": "/zagreus/src/views/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gaku-sei/zagreus-identity-provider path: /zagreus/src/views/mod.rs use actix_web::{http::StatusCode, HttpRequest, HttpResponse, Responder, ResponseError}; use serde::Serialize; use std::path::Path; use tera::{Context, Error, ErrorKind, Tera}; use thiserror::Error; pub mod home; pub mod invitati...
code_fim
hard
{ "lang": "rust", "repo": "gaku-sei/zagreus-identity-provider", "path": "/zagreus/src/views/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DavidVranish/rust_graphql path: /src/http.rs extern crate tiny_http; pub fn start_http_server(arg_ip: String, arg_port: u32) -> () { let loc_address_string: String = format!("{}:{}", arg_ip, arg_port.to_string()); let loc_server = tiny_http::Server::http(loc_address_string).unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "DavidVranish/rust_graphql", "path": "/src/http.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> handle_request(loc_request); } } fn handle_request(arg_request: tiny_http::Request) -> () { println!("{}", arg_request.method()); let loc_response_string = String::from("woooooo!"); let loc_reponse = tiny_http::Response::from_string(loc_response_string); let _ = arg_request.r...
code_fim
medium
{ "lang": "rust", "repo": "DavidVranish/rust_graphql", "path": "/src/http.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", arg_request.method()); let loc_response_string = String::from("woooooo!"); let loc_reponse = tiny_http::Response::from_string(loc_response_string); let _ = arg_request.respond(loc_reponse); }<|fim_prefix|>// repo: DavidVranish/rust_graphql path: /src/http.rs extern crate t...
code_fim
medium
{ "lang": "rust", "repo": "DavidVranish/rust_graphql", "path": "/src/http.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmvict/wTools path: /rust/impl/derive/clone_dyn_meta/meta_impl.rs use proc_macro_tools::prelude::*; pub type Result< T > = std::result::Result< T, syn::Error >; // pub fn clone_dyn( _attr : proc_macro::TokenStream, item : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > { le...
code_fim
hard
{ "lang": "rust", "repo": "dmvict/wTools", "path": "/rust/impl/derive/clone_dyn_meta/meta_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } impl < 'c, #generics_params > Clone for Box< dyn #name_ident< #( #generics_names ),* > + Send + Sync + 'c > // where #generics_where { #[ inline ] fn clone( &self ) -> Self { clone_dyn::_clone_boxed( &**self ) } } }; Ok( result ) }<|fim_prefix|>// repo: d...
code_fim
hard
{ "lang": "rust", "repo": "dmvict/wTools", "path": "/rust/impl/derive/clone_dyn_meta/meta_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emrecelikten/adventofcode2020 path: /d13/src/main.rs fn read_data(filename: &str) -> String { std::fs::read_to_string(filename).unwrap() } fn parse_data(data: &str) -> (i32, Vec<i32>) { let mut lines = data.lines(); let cur_time = lines.nth(0).unwrap().parse().unwrap(); let bus_...
code_fim
hard
{ "lang": "rust", "repo": "emrecelikten/adventofcode2020", "path": "/d13/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (cur_time, bus_times) = parse_data(&TEST_DATA); let (id, min_wait) = find_earliest_bus(&cur_time, &bus_times); assert_eq!(id, 59); assert_eq!(min_wait, 5); } #[test] fn test_find_earliest_time() { let (_, bus_times) = parse_data(&TEST_DATA); ...
code_fim
hard
{ "lang": "rust", "repo": "emrecelikten/adventofcode2020", "path": "/d13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; const TEST_DATA: &'static str = r"939 7,13,x,x,59,x,31,19"; const TEST_DATA_2: &'static str = r"0 1789,37,47,1889"; #[test] fn test_find_earliest_bus() { let (cur_time, bus_times) = parse_data(&TEST_DATA); let (id, min_wait) = f...
code_fim
hard
{ "lang": "rust", "repo": "emrecelikten/adventofcode2020", "path": "/d13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn inorder(&self) -> IterInorder<T> { match self.root { Some(ref root) => root.inorder(), None => IterInorder::null(), } } pub fn postorder(&self) -> IterPostorder<T> { match self.root { Some(ref root) => root.postorder(), ...
code_fim
hard
{ "lang": "rust", "repo": "Oaklight/RustPractice", "path": "/hw2/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Oaklight/RustPractice path: /hw2/src/lib.rs type Link<T> = Option<Box<Node<T>>>; #[derive(Debug)] struct Node<T> { key: T, left: Link<T>, right: Link<T>, } pub struct Tree<T> { root: Link<T>, } impl <T: Ord> Node<T> { fn new_link(key: T) -> Link<T> { Some(Box::new(N...
code_fim
hard
{ "lang": "rust", "repo": "Oaklight/RustPractice", "path": "/hw2/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { match self.peek() { Some(c) if is_id_char(c) => { self.advance(); } _ => { break; } } } let text: String = self.chars[self.start..self.current].ite...
code_fim
hard
{ "lang": "rust", "repo": "raffalevy/math_parser", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raffalevy/math_parser path: /src/lexer.rs use std::fmt::{self, Display}; pub fn scan(source: String) -> Vec<Token> { let mut lexer = Lexer::new(source); let mut tokens: Vec<Token> = vec![]; loop { match lexer.scan_token() { Some(token) => tokens.push(token), ...
code_fim
hard
{ "lang": "rust", "repo": "raffalevy/math_parser", "path": "/src/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug, Clone)] pub struct Subscribe { pub channel: String, }<|fim_prefix|>// repo: hagsteel/pubsub path: /src/messages.rs use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Debug, Clone)] pub struct PubMessage { pub channel: String, pub pay...
code_fim
medium
{ "lang": "rust", "repo": "hagsteel/pubsub", "path": "/src/messages.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hagsteel/pubsub path: /src/messages.rs use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Debug, Clone)] pub struct PubMessage { pub channel: String, pub payload: String, } <|fim_suffix|>#[derive(Deserialize, Serialize, Debug, Clone)] pub struct Subscribe { pub c...
code_fim
medium
{ "lang": "rust", "repo": "hagsteel/pubsub", "path": "/src/messages.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> srs_data_ccw(piece, rot) } } //---------------------------------------------------------------- struct Mesh { pub data: [Sprite; 4], } macro_rules! b { (____) => (0b0000); (___X) => (0b0001); (__X_) => (0b0010); (__XX) => (0b0011); (_X__) => (0b0100); (_X_X) => (0b0101); (_XX_) => (0b0110); ...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/tetrs", "path": "/tetrs/src/rules/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct Mesh { pub data: [Sprite; 4], } macro_rules! b { (____) => (0b0000); (___X) => (0b0001); (__X_) => (0b0010); (__XX) => (0b0011); (_X__) => (0b0100); (_X_X) => (0b0101); (_XX_) => (0b0110); (_XXX) => (0b0111); (X___) => (0b1000); (X__X) => (0b1001); (X_X_) => (0b1010); (X_XX) => (0b101...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/tetrs", "path": "/tetrs/src/rules/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CasualX/tetrs path: /tetrs/src/rules/mod.rs /*! Customize the rules for the tetris game. */ use ::{Piece, Rot, Point, Sprite, srs_data_cw, srs_data_ccw}; /// Tetris rule customization. pub trait Rules: Copy { /// The 4x4 sprite for the given piece and rotation. fn piece_sprite(&self, piece: ...
code_fim
hard
{ "lang": "rust", "repo": "CasualX/tetrs", "path": "/tetrs/src/rules/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenalexchen/nes_emulator_rust path: /nes_emulator/src/cpu.rs er = 0; if self.reg_status.contains(Status::C) { carrier = 0b1000_0000; } else { carrier = 0b0000_0000; } match addr_mode { AddressingMode::Accumulator => { ...
code_fim
hard
{ "lang": "rust", "repo": "chenalexchen/nes_emulator_rust", "path": "/nes_emulator/src/cpu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>type InstructionHandler = fn(&mut CPU, &AddressingMode); lazy_static! { static ref INSTRUCTION_HANDLERS: HashMap<u8, InstructionHandler> = { let mut map: HashMap<u8, InstructionHandler> = HashMap::new(); map.insert(OPCODE_ADC_IMMEDIATE, CPU::adc); map.insert(OPCODE_ADC_ZEROPA...
code_fim
hard
{ "lang": "rust", "repo": "chenalexchen/nes_emulator_rust", "path": "/nes_emulator/src/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenalexchen/nes_emulator_rust path: /nes_emulator/src/cpu.rs program), Ok(())); assert_eq!(cpu.reg_a, 0x00); assert_eq!(cpu.read_mem(0x00f0), 0x00); assert_eq!(cpu.reg_status.contains(Status::C), false); assert_eq!(cpu.reg_status.contains(Status::N), false); assert_eq!(cpu....
code_fim
hard
{ "lang": "rust", "repo": "chenalexchen/nes_emulator_rust", "path": "/nes_emulator/src/cpu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn check_image_access(&self, image: &ImageAccess, exclusive: bool, queue: &Queue) -> Result<Option<(PipelineStages, AccessFlagBits)>, ()> { Err(()) } } unsafe impl DeviceOwned for DummyFuture { #[inline] fn device(&self) -> &Arc<Device>...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/vulkano", "path": "/vulkano/src/sync/future/dummy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ralith/vulkano path: /vulkano/src/sync/future/dummy.rs // Copyright (c) 2017 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, //...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/vulkano", "path": "/vulkano/src/sync/future/dummy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> true } #[inline] fn queue(&self) -> Option<&Arc<Queue>> { None } #[inline] fn check_buffer_access(&self, buffer: &BufferAccess, exclusive: bool, queue: &Queue) -> Result<Option<(PipelineStages, AccessFlagBits)>, ()> { Err(())...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/vulkano", "path": "/vulkano/src/sync/future/dummy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ikegam1/clova_webhook_utils path: /src/response.rs use std::error::Error; //==== Response #[derive(Serialize, Deserialize, Debug)] pub struct ResponseDataStruct{ version: String, #[serde(default)] response: serde_json::Value, #[serde(rename="sessionAttributes")] session_attr...
code_fim
hard
{ "lang": "rust", "repo": "ikegam1/clova_webhook_utils", "path": "/src/response.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut res: ResponseDataStruct = ResponseDataStruct::new().unwrap(); res.set_simple_speech_text("hello world".to_string(), false); res.set_reprompt_simple_speech_text("hello world?".to_string()); res.set_session_attributes_from_str("{\"key\":\"value\"}".to_string()); ...
code_fim
medium
{ "lang": "rust", "repo": "ikegam1/clova_webhook_utils", "path": "/src/response.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ToTokens for CssBlockQualifier { fn to_tokens(&self, tokens: &mut TokenStream) { for q in self.qualifiers.iter() { q.to_tokens(tokens); } } } impl CssBlockQualifier { pub fn into_output(self, ctx: &mut IntoOutputContext) -> Vec<OutputSelector> { ctx.ex...
code_fim
hard
{ "lang": "rust", "repo": "00mjk/stylist-rs", "path": "/packages/stylist-macros/src/inline/parse/qualifier.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn is_not_comma(q: &ComponentValue) -> bool { !matches!(q, ComponentValue::Token(PreservedToken::Punct(ref p)) if p.as_char() == ',') } self.qualifiers .into_iter() .peekable() .batching(|it| { // Return if no items l...
code_fim
hard
{ "lang": "rust", "repo": "00mjk/stylist-rs", "path": "/packages/stylist-macros/src/inline/parse/qualifier.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 00mjk/stylist-rs path: /packages/stylist-macros/src/inline/parse/qualifier.rs use super::{ super::component_value::{ComponentValue, ComponentValueStream, PreservedToken}, fragment_spacing, IntoOutputContext, }; use crate::{output::OutputSelector, spacing_iterator::SpacedIterator}; use it...
code_fim
hard
{ "lang": "rust", "repo": "00mjk/stylist-rs", "path": "/packages/stylist-macros/src/inline/parse/qualifier.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..10 { let len = rand::thread_rng().gen_range(5, 50); let mut vec = Vec::new(); for _ in 0..len { vec.push(rand::thread_rng().gen_range(-100, 100)); } assert_eq!(find_smallest_int(&vec[..len]), solution(&vec[..l...
code_fim
hard
{ "lang": "rust", "repo": "torresng/Codewars-Rust", "path": "/Fundamentals/find_the_smallest_integer_in_the_array/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn more_tests() { assert_eq!(find_smallest_int(&[78, 56, 232, 12, 8]), 8); assert_eq!(find_smallest_int(&[78, 56, 232, 12, 18]), 12); assert_eq!(find_smallest_int(&[78, 56, 232, 412, 228]), 56); assert_eq!(find_smallest_int(&[78, 56, 232, 12, 0]), 0); ...
code_fim
hard
{ "lang": "rust", "repo": "torresng/Codewars-Rust", "path": "/Fundamentals/find_the_smallest_integer_in_the_array/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: torresng/Codewars-Rust path: /Fundamentals/find_the_smallest_integer_in_the_array/src/lib.rs pub fn find_smallest_int(arr: &[i32]) -> i32 { *arr.iter().min().unwrap() } #[cfg(test)] mod tests { use super::*; extern crate rand; #[allow(unused_imports)] use self::rand::Rng; <...
code_fim
hard
{ "lang": "rust", "repo": "torresng/Codewars-Rust", "path": "/Fundamentals/find_the_smallest_integer_in_the_array/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KuekenPartei/proofmarshal path: /hoard/src/blob/impls/tuples.rs use std::error::Error; use thiserror::Error; use super::*; #[derive(Debug, Error, PartialEq, Eq)] #[error("FIXME")] pub enum DecodeTupleBytesError< T0: Error, T1: Error = !, T2: Error = !, T3: Error = !, T4: E...
code_fim
hard
{ "lang": "rust", "repo": "KuekenPartei/proofmarshal", "path": "/hoard/src/blob/impls/tuples.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tuple! ( T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0, ); #[cfg(test)] mod tests { use super::*; use std::fmt; #[test] fn encode_bytes() { #[track_caller] fn t<T: Blob>(value: T, expected: &[u8]) { let actual = value.to_blob_bytes(); assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "KuekenPartei/proofmarshal", "path": "/hoard/src/blob/impls/tuples.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bbenligiray/api3-dao-tracker path: /client/src/screens/home.rs ate::state::AppState; use sauron::prelude::*; use serde::{Deserialize, Serialize}; use web3::types::U256; #[derive(Debug, Serialize, Deserialize)] pub struct Screen { /// server side state pub state: AppState, } impl Screen...
code_fim
hard
{ "lang": "rust", "repo": "bbenligiray/api3-dao-tracker", "path": "/client/src/screens/home.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> <h2>"API3 Staking Rewards"</h2> <div class="dash-row"> {self.current_epoch("dash-col dash-col-3")} {self.render_epoch(1, "dash-col dash-col-3")} {self.render_epoch(2, "dash-c...
code_fim
hard
{ "lang": "rust", "repo": "bbenligiray/api3-dao-tracker", "path": "/client/src/screens/home.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> node! { <div class="screen-home"> { header::render("", &self.state) } <div class="inner"> <div class="centered"> <h1>"API3 DAO Tracker"</h1> <p class="m20"> "...
code_fim
hard
{ "lang": "rust", "repo": "bbenligiray/api3-dao-tracker", "path": "/client/src/screens/home.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dorucioclea/omics path: /publishing/domain/interaction/stars.rs use common::error::Error; use common::result::Result; #[derive(Debug, Clone, PartialEq)] pub struct Stars { stars: u8, } <|fim_suffix|> pub fn value(&self) -> u8 { self.stars } }<|fim_middle|>impl Stars { pu...
code_fim
medium
{ "lang": "rust", "repo": "dorucioclea/omics", "path": "/publishing/domain/interaction/stars.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Stars { pub fn new(stars: u8) -> Result<Self> { if stars > 5 { return Err(Error::new("stars", "invalid_range")); } Ok(Stars { stars }) } pub fn value(&self) -> u8 { self.stars } }<|fim_prefix|>// repo: dorucioclea/omics path: /publishing/...
code_fim
medium
{ "lang": "rust", "repo": "dorucioclea/omics", "path": "/publishing/domain/interaction/stars.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct BinaryError01 {} // use for binary problems with l1/l2 -> choose closest to 0,1 instead of -1, 1 impl_metric!(BinaryError01, eval_one: |_, t: NumT, p: NumT| { if t < 0.5 { if p < 0.5 { 0.0 } else { 1.0 } } else { if p < 0.5 { 1.0 } else { 0.0 ...
code_fim
hard
{ "lang": "rust", "repo": "laudv/bitboost", "path": "/src/metric.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct BinaryLoss {} impl_metric!(BinaryLoss, eval_one: |_, t: NumT, p: NumT| { let y = 2.0 * t - 1.0; (1.0 + (-2.0 * y * p).exp()).ln() }); impl BinaryLoss { pub fn new() -> BinaryLoss { BinaryLoss {} } } // -------------------------------------------------------------------------------...
code_fim
hard
{ "lang": "rust", "repo": "laudv/bitboost", "path": "/src/metric.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laudv/bitboost path: /src/metric.rs /* * Copyright 2019 DTAI Research Group - KU Leuven. * License: Apache License 2.0 * Author: Laurens Devos */ use crate::{NumT}; macro_rules! impl_metric { ($type:ty, eval_one: $impl:expr) => { impl_metric!($type, eval_all: |this: &$type, ta...
code_fim
hard
{ "lang": "rust", "repo": "laudv/bitboost", "path": "/src/metric.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }