text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: thorhs/mk66f18 path: /src/fmc/pfb01cr.rs
]
pub enum B0IPE_A {
#[doc = "0: Do not prefetch in response to instruction fetches."]
_0,
#[doc = "1: Enable prefetches in response to instruction fetches."]
_1,
}
impl From<B0IPE_A> for bool {
#[inline(always)]
fn from(variant: B... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/fmc/pfb01cr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match variant {
CLCK_WAY_A::_0 => 0,
CLCK_WAY_A::_1 => 1,
}
}
}
#[doc = "Reader of field `CLCK_WAY`"]
pub type CLCK_WAY_R = crate::R<u8, CLCK_WAY_A>;
impl CLCK_WAY_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) ... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/fmc/pfb01cr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match variant {
B0ICE_A::_0 => false,
B0ICE_A::_1 => true,
}
}
}
#[doc = "Reader of field `B0ICE`"]
pub type B0ICE_R = crate::R<bool, B0ICE_A>;
impl B0ICE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> B0ICE_... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/fmc/pfb01cr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andygrove/arrow-rs path: /parquet/src/arrow/record_reader/mod.rs
let expected_buffer = bb.finish();
assert_eq!(expected_buffer, record_reader.consume_record_data());
assert_eq!(None, record_reader.consume_def_levels());
assert_eq!(None, record_reader.consume_bitma... | code_fim | hard | {
"lang": "rust",
"repo": "andygrove/arrow-rs",
"path": "/parquet/src/arrow/record_reader/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andygrove/arrow-rs path: /parquet/src/arrow/record_reader/mod.rs
nLevelDecoderImpl;
use crate::column::{
page::PageReader,
reader::{
decoder::{ColumnValueDecoder, ColumnValueDecoderImpl},
GenericColumnReader,
},
};
use crate::data_type::DataType;
use crate::errors::{P... | code_fim | hard | {
"lang": "rust",
"repo": "andygrove/arrow-rs",
"path": "/parquet/src/arrow/record_reader/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Construct column schema
let message_type = "
message test_schema {
REPEATED Group test_struct {
REPEATED INT32 leaf;
}
}
";
let desc = parse_message_type(message_type)
.map(|t| SchemaDescriptor::new(Arc::new(t... | code_fim | hard | {
"lang": "rust",
"repo": "andygrove/arrow-rs",
"path": "/parquet/src/arrow/record_reader/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = res {
return Err(e);
} else {
return Ok(false);
}
}
_ => return Err(CpuError::InvalidRegisterValueType),
};
}
}
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "sciguyryan/oxidation",
"path": "/oxidation-core/src/instructions/implementations.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sciguyryan/oxidation path: /oxidation-core/src/instructions/implementations.rs
use crate::cpu::*;
use crate::registers::*;
use crate::security_context::SecurityContext;
type Result<T, E = CpuError> = std::result::Result<T, E>;
<|fim_suffix|> if let Err(e) = res {
... | code_fim | hard | {
"lang": "rust",
"repo": "sciguyryan/oxidation",
"path": "/oxidation-core/src/instructions/implementations.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0725_split_linked_list_in_parts/mod.rs
use crate::data_structures::ListNode;
pub mod two_passes;
pub trait Solution {
fn split_list_to_parts(head: Option<Box<ListNode>>, k: i32) -> Vec<Option<Box<ListNode>>>;
<|fim_suffix|> pub fn run<S: Solution>() {
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0725_split_linked_list_in_parts/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ((head, k), expected) in test_cases {
assert_eq!(
S::split_list_to_parts(test_utilities::make_list(head.iter().copied()), k)
.iter()
.map(|list| test_utilities::iter_list(list).copied().collect::<Vec<_>>())
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0725_split_linked_list_in_parts/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut config = Config::new();
if let Some(path) = config_path {
config.merge(File::with_name(path.as_ref().to_str().unwrap()))?;
}
Ok(config)
}
fn process_arg(arg_name: &str, arg_value: &Option<String>, config: &mut Config) -> Result<(), failure::Error> {
if let Some(ref v... | code_fim | hard | {
"lang": "rust",
"repo": "hcpl/tg-tui",
"path": "/src/args.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hcpl/tg-tui path: /src/args.rs
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use app_dirs::{AppDataType, AppInfo, get_app_dir};
use config::{Config, File};
use failure;
use structopt::StructOpt;
use app_config::AppConfig;
const APP_INFO: AppInfo = AppInfo { name: crate_name!... | code_fim | hard | {
"lang": "rust",
"repo": "hcpl/tg-tui",
"path": "/src/args.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>///Spawned actor reference with no port and channel
pub struct ActorRefWithoutPortAndChan;
impl ActorRef for ActorRefWithoutPortAndChan{}<|fim_prefix|>// repo: nielsle/rust-actor-experiments path: /src/actor/actorref.rs
///A reference to a spawned actorpub trait ActorRef { }
pub trait ActorRef{ }
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "nielsle/rust-actor-experiments",
"path": "/src/actor/actorref.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nielsle/rust-actor-experiments path: /src/actor/actorref.rs
///A reference to a spawned actorpub trait ActorRef { }
pub trait ActorRef{ }
<|fim_suffix|>///Spawned actor reference with channel
pub struct ActorRefWithChan<C1>{
chan: C1,
}
impl<T1: Send, C1: GenericChan<T1>> ActorRef for Acto... | code_fim | hard | {
"lang": "rust",
"repo": "nielsle/rust-actor-experiments",
"path": "/src/actor/actorref.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
///Spawned actor reference with no port and channel
pub struct ActorRefWithoutPortAndChan;
impl ActorRef for ActorRefWithoutPortAndChan{}<|fim_prefix|>// repo: nielsle/rust-actor-experiments path: /src/actor/actorref.rs
///A reference to a spawned actorpub trait ActorRef { }
pub trait ActorRef{ }
///S... | code_fim | hard | {
"lang": "rust",
"repo": "nielsle/rust-actor-experiments",
"path": "/src/actor/actorref.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>x2>100 && num/x2<999
});
if deliver.is_some() {
max = num;
break;
}
}
println!("result: {} {} {}", num, deliver.unwrap(), num/deliver.unwrap() );
}<|fim_prefix|>// repo: vladimirovmm/projecteuler_solving_problems path: /src/lesson4/mod.rs
///
//... | code_fim | hard | {
"lang": "rust",
"repo": "vladimirovmm/projecteuler_solving_problems",
"path": "/src/lesson4/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vladimirovmm/projecteuler_solving_problems path: /src/lesson4/mod.rs
///
/// https://projecteuler.net/problem=4
///
/// Число-палиндром с обеих сторон (справа налево и слева направо) читается одинаково.
/// Самое большое число-палиндром, полученное умножением двух двузначных<|fim_suffix|>x2>100 ... | code_fim | hard | {
"lang": "rust",
"repo": "vladimirovmm/projecteuler_solving_problems",
"path": "/src/lesson4/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sender = SmtpTransportBuilder::new("127.0.0.1:2525")
.unwrap()
.security_level(SecurityLevel::Opportunistic)
.build();
let email = EmailBuilder::new()
.to("root@localhost")
.from("user@localhost")
.body("Hello World!")
.subject("Hello... | code_fim | medium | {
"lang": "rust",
"repo": "mpietrzak/lettre",
"path": "/tests/transport_smtp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mpietrzak/lettre path: /tests/transport_smtp.rs
extern crate lettre;
use lettre::email::EmailBuilder;
use lettre::transport::EmailTransport;
use lettre::transport::smtp::SecurityLevel;
use lettre::transport::smtp::SmtpTransportBuilder;
<|fim_suffix|> let mut sender = SmtpTransportBuilder::n... | code_fim | medium | {
"lang": "rust",
"repo": "mpietrzak/lettre",
"path": "/tests/transport_smtp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ICRA-2021/lynx path: /lynx_rust/src/utils/utils_math/interpolation_utils.rs
use nalgebra::{DVector, Vector3};
use crate::utils::utils_math::nalgebra_utils::vec_to_dvec;
pub fn get_linear_interpolation_with_stepsize(start_pt: &DVector<f64>, goal_pt: &DVector<f64>, step_size: f64) -> Vec<DVector<... | code_fim | medium | {
"lang": "rust",
"repo": "ICRA-2021/lynx",
"path": "/lynx_rust/src/utils/utils_math/interpolation_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_linear_interpolation(start: f64, end: f64, u: f64) -> f64 {
/*
u is a value between 0.0 and 1.0 that will be used to interpolate between start and end
*/
return (1.0 - u) * start + (u) * end;
}
pub fn get_linear_ramp_value_within_range(ramp_start: f64, ramp_end: f64, range_sta... | code_fim | hard | {
"lang": "rust",
"repo": "ICRA-2021/lynx",
"path": "/lynx_rust/src/utils/utils_math/interpolation_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: higumachan/dobot-api-rs path: /src/protocol/message.rs
use crate::protocol::packet::SYNC_BYTE;
use crate::protocol::protocol_id::ProtocolID;
use byteorder::{LittleEndian, ReadBytesExt};
use nom::lib::std::fmt::{Debug, Formatter};
use std::io::{Cursor, Read, Write};
const MAX_PAYLOAD_SIZE: u8 =... | code_fim | hard | {
"lang": "rust",
"repo": "higumachan/dobot-api-rs",
"path": "/src/protocol/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> buf[0] = *self;
1
}
}
impl ToParamable for bool {
fn to_params(&self, buf: &mut [u8]) -> usize {
buf[0] = if *self { 1 } else { 0 };
1
}
}
impl<T: ToParamable> ToParams for T {
fn to_params(&self) -> std::io::Result<(usize, [u8; PARAMS_SIZE])> {
le... | code_fim | hard | {
"lang": "rust",
"repo": "higumachan/dobot-api-rs",
"path": "/src/protocol/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vlmonk/advent2019 path: /day04/src/main.rs
use std::time::Instant;
#[derive(Debug, PartialEq, PartialOrd)]
struct Num([u8; 6]);
impl Num {
fn from_i32(input: i32) -> Self {
let d0 = ((input / 100_000) % 10) as u8;
let d1 = ((input / 10_000) % 10) as u8;
let d2 = ((i... | code_fim | hard | {
"lang": "rust",
"repo": "vlmonk/advent2019",
"path": "/day04/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut task_a = 0;
let mut task_b = 0;
loop {
if is_increase(&c) {
if is_2_digit_same(&c) {
task_a += 1;
}
if is_2_digit_same_advanced(&c) {
task_b += 1;
}
}
c.inc();
if c > max... | code_fim | hard | {
"lang": "rust",
"repo": "vlmonk/advent2019",
"path": "/day04/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> type Error = UseCaseError;
const NAME: &'static str = "RemoveUserFromService";
async fn execute(&mut self, ctx: &NettuContext) -> Result<Self::Response, Self::Error> {
let service = match ctx.repos.services.find(&self.service_id).await {
Some(service) if service.account_i... | code_fim | hard | {
"lang": "rust",
"repo": "gamsb/nettu-scheduler",
"path": "/scheduler/crates/api/src/service/remove_user_from_service.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gamsb/nettu-scheduler path: /scheduler/crates/api/src/service/remove_user_from_service.rs
use crate::{
error::NettuError,
shared::{
auth::protect_account_route,
usecase::{execute, UseCase},
},
};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api... | code_fim | hard | {
"lang": "rust",
"repo": "gamsb/nettu-scheduler",
"path": "/scheduler/crates/api/src/service/remove_user_from_service.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> req.extensions_mut().insert(RepoHeadersData {
nocache: true,
});
let commit_refs = commit.metadata.get("ostree.ref-binding").ok_or (ApiError::InternalServerError(format!("No ref binding for commit {:?}", path)))?.as_string_vec()?;
let mut result = Ok(());
// If there are any n... | code_fim | hard | {
"lang": "rust",
"repo": "ignatenkobrain/flat-manager",
"path": "/src/app.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ignatenkobrain/flat-manager path: /src/app.rs
eb::dev::Server;
use actix_files::NamedFile;
use actix_web::http::header::{CACHE_CONTROL, HeaderValue};
use actix_web::web::Data;
use actix_web::Responder;
use actix_service::{Service};
use std::path::PathBuf;
use std::path::Path;
use std::ffi::OsStr... | code_fim | hard | {
"lang": "rust",
"repo": "ignatenkobrain/flat-manager",
"path": "/src/app.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let relpath = canonicalize_path(tail.trim_start_matches('/'))?;
let realid = canonicalize_path(id)?;
let path = Path::new(&config.build_repo_base).join(&realid).join(&relpath);
if path.is_dir() {
return Err(ErrorNotFound("Ignoring directory"));
}
NamedFile::open(path).or_e... | code_fim | hard | {
"lang": "rust",
"repo": "ignatenkobrain/flat-manager",
"path": "/src/app.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aggresss/playground-rust path: /algorithm/src/graph/mod.rs
mod depth_first_search;
pub use self::depth_first_search::depth_first_search;
<|fim_suffix|>mod disjoint_set_union;
pub use self::disjoint_set_union::DisjointSetUnion;
mod prim;
pub use self::prim::{prim, prim_with_start};
mod kruskal... | code_fim | medium | {
"lang": "rust",
"repo": "aggresss/playground-rust",
"path": "/algorithm/src/graph/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod topological_sort;
pub use self::topological_sort::topological_sort;
mod tarjan;
pub use self::tarjan::StronglyConnectedComponents;
mod dijkstra;
pub use self::dijkstra::dijkstra;<|fim_prefix|>// repo: aggresss/playground-rust path: /algorithm/src/graph/mod.rs
mod depth_first_search;
pub use self::d... | code_fim | medium | {
"lang": "rust",
"repo": "aggresss/playground-rust",
"path": "/algorithm/src/graph/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_rolls(&self) -> u64 {
self.rolls
}
pub fn set_rolls(&mut self, input: u64) {
self.rolls = input;
}
pub fn roll(&mut self) {
self.rolls += 1;
}
// pub fn print_values(&self) {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "El-Chapo0133/enigma-machine_rs",
"path": "/src/machine/rotor/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: El-Chapo0133/enigma-machine_rs path: /src/machine/rotor/mod.rs
pub struct Rotor {
values: Vec<char>,
pub values_len: usize,
pub rolls: u64,
}
impl Rotor {
pub fn new(values: Vec<char>) -> Rotor {
Rotor {
values: values,
... | code_fim | hard | {
"lang": "rust",
"repo": "El-Chapo0133/enigma-machine_rs",
"path": "/src/machine/rotor/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let params = if params.is_empty() {
None
} else {
Some(&*params)
};
let mut args = MssqlArguments::default();
args.declare("", 0_i32);
args.add_unnamed(params);
args.add_unnamed(sql);
args.add_unnamed(0x0001_i32); // 1 = SEND_METADATA
conn.stream.writ... | code_fim | hard | {
"lang": "rust",
"repo": "thedodd/sqlx",
"path": "/sqlx-core/src/mssql/connection/prepare.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> conn.stream.flush().await?;
conn.stream.wait_until_ready().await?;
conn.stream.pending_done_count += 1;
let mut id: Option<i32> = None;
loop {
let message = conn.stream.recv_message().await?;
match message {
Message::DoneProc(done) | Message::Done(done) =... | code_fim | hard | {
"lang": "rust",
"repo": "thedodd/sqlx",
"path": "/sqlx-core/src/mssql/connection/prepare.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thedodd/sqlx path: /sqlx-core/src/mssql/connection/prepare.rs
use crate::decode::Decode;
use crate::error::Error;
use crate::mssql::protocol::done::Status;
use crate::mssql::protocol::message::Message;
use crate::mssql::protocol::packet::PacketType;
use crate::mssql::protocol::rpc::{OptionFlags,... | code_fim | hard | {
"lang": "rust",
"repo": "thedodd/sqlx",
"path": "/sqlx-core/src/mssql/connection/prepare.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xd009642/rust-sandbox path: /src/main.rs
fn say_hello() {
println!("Hello, world!");
}
fn main() {
say_hello();
}
<|fim_suffix|> println!("Running a test");
say_hello();
}<|fim_middle|>#[test]
fn test() {
| code_fim | easy | {
"lang": "rust",
"repo": "xd009642/rust-sandbox",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test() {
println!("Running a test");
say_hello();
}<|fim_prefix|>// repo: xd009642/rust-sandbox path: /src/main.rs
fn say_hello() {
<|fim_middle|> println!("Hello, world!");
}
fn main() {
say_hello();
}
| code_fim | medium | {
"lang": "rust",
"repo": "xd009642/rust-sandbox",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ijkuyews/uefi-kernel path: /src/memory/frame_allocator.rs
use bootloader::boot_info::{MemoryRegionKind, MemoryRegions};
use x86_64::{
structures::paging::{FrameAllocator, PhysFrame, Size4KiB},
PhysAddr,
};
pub struct GlobalFrameAllocator {
mem_maps: &'static MemoryRegions,
next: usize,
... | code_fim | medium | {
"lang": "rust",
"repo": "ijkuyews/uefi-kernel",
"path": "/src/memory/frame_allocator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe impl Send for GlobalFrameAllocator {}
unsafe impl Sync for GlobalFrameAllocator {}
unsafe impl FrameAllocator<Size4KiB> for GlobalFrameAllocator {
fn allocate_frame(&mut self) -> Option<PhysFrame> {
self.next += 1;
self.usable_frames().nth(self.next - 1)
}
}<|fim_prefix|>// repo: ijkuy... | code_fim | hard | {
"lang": "rust",
"repo": "ijkuyews/uefi-kernel",
"path": "/src/memory/frame_allocator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sdaveas/aoc_2020 path: /day5/src/main.rs
use std::error::Error;
use std::fs::File;
use std::io::{prelude::*, BufReader};
use std::collections::HashMap;
fn get_input(filename: &str) -> Result<Vec<String>, Box<dyn Error>>{
let reader = BufReader::new(File::open(filename)?);
let mut input=... | code_fim | medium | {
"lang": "rust",
"repo": "sdaveas/aoc_2020",
"path": "/day5/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> row*8+seat
}
fn main() -> Result<(), Box<dyn Error>> {
let boardings = get_input("input.txt")?;
let mut seats = HashMap::new();
let mut min = 128 * 8 + 7;
let mut max = 0;
for boarding in boardings {
let row = parse_as_bin(&boarding[0..7], 'F', 'B');
let seat = p... | code_fim | medium | {
"lang": "rust",
"repo": "sdaveas/aoc_2020",
"path": "/day5/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChristoffenOSWorks/PandaCat-Rust path: /src/main.rs
extern crate toCairo;
extern crate rustyline;
fn main() {
if std::process::Com<|fim_suffix|>tyline::Editor::<()>::new();
let readline = rl.readline(">> ");
}
}<|fim_middle|>mand::new("clear").status().unwrap(... | code_fim | medium | {
"lang": "rust",
"repo": "ChristoffenOSWorks/PandaCat-Rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tyline::Editor::<()>::new();
let readline = rl.readline(">> ");
}
}<|fim_prefix|>// repo: ChristoffenOSWorks/PandaCat-Rust path: /src/main.rs
extern crate toCairo;
extern crate rustyline;
fn main() {
if std::process::Com<|fim_middle|>mand::new("clear").status().unwrap(... | code_fim | medium | {
"lang": "rust",
"repo": "ChristoffenOSWorks/PandaCat-Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sudipghimire533/Add-Sub-lang path: /rust_sudipghimire533.rs
fn add(lhs: u32, rhs: u32) -> u32 {
<|fim_suffix|> println!("Sum of 10 and 20 is {}", sum(10, 20));
println!("Difference of 20 and 10 is {}", diff(20, 10));
}<|fim_middle|> let sum = lhs + rhs;
sum
}
fn sub(big: u32, small: u32)... | code_fim | medium | {
"lang": "rust",
"repo": "sudipghimire533/Add-Sub-lang",
"path": "/rust_sudipghimire533.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("Sum of 10 and 20 is {}", sum(10, 20));
println!("Difference of 20 and 10 is {}", diff(20, 10));
}<|fim_prefix|>// repo: sudipghimire533/Add-Sub-lang path: /rust_sudipghimire533.rs
fn add(lhs: u32, rhs: u32) -> u32 {
let sum = lhs + rhs;
sum
}
<|fim_middle|>fn sub(big: u32,... | code_fim | medium | {
"lang": "rust",
"repo": "sudipghimire533/Add-Sub-lang",
"path": "/rust_sudipghimire533.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanpianka/leetcode-rust path: /src/easy/string/long_pressed_name.rs
/** https://leetcode.com/problems/long-pressed-name/
官方解答: 直接双指针
```go
func isLongPressedName(name uncategorized, typed uncategorized) bool {
i, j := 0, 0
for j < len(typed) {
if i < len(name) && name[i] == type... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/leetcode-rust",
"path": "/src/easy/string/long_pressed_name.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/**
虽然解法比较繁琐丑陋,但是学到了peekableIterator,复习下迭代器的种类
- peekable(peek, next_if)
- take_while(类似peekable迭代器的next_if,能接收过滤条件的迭代器)
- skip_while(和take_while相反,跳过满足过滤条件的元素)
- scan(类似fold/reduce)
- cycle(循环)
- fuse(遇到第一个None就停掉)
迭代器好用的API: inspect(允许chain迭代器时中途打印某层的值), partition(consume迭代器,将其根据条件分成两个Vec,用于快速排序)
*/
fn... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/leetcode-rust",
"path": "/src/easy/string/long_pressed_name.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nkoehring/k0r path: /src/actix_ructe.rs
use actix_web::body::Body;
use std::io::Write;
#[macro_export]
macro_rules! render {
($template:path) => (super::actix_ructe::Render(|o| $template(o)));
($template:path, $($arg:expr),*) => {{
use crate::actix_ructe::Render;
Render(... | code_fim | medium | {
"lang": "rust",
"repo": "nkoehring/k0r",
"path": "/src/actix_ructe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buf = Vec::new();
match t.0(&mut buf) {
Ok(()) => buf.into(),
Err(_e) => {
//log::warn!("Failed to render: {}", e);
"Render failed".into()
}
}
}
}<|fim_prefix|>// repo: nkoehring/k0r path: /src/actix_r... | code_fim | medium | {
"lang": "rust",
"repo": "nkoehring/k0r",
"path": "/src/actix_ructe.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn store_mem() -> Sym<f64, InstrState> {
let f: Rc<dyn Fn(&mut Vec<f64>, &mut InstrState)> =
Rc::new(move |stack: &mut Vec<f64>, state: &mut InstrState| {
let addr = stack.pop().unwrap();
let arg = stack.pop().unwrap();
if addr >= 0.0 && (addr as us... | code_fim | hard | {
"lang": "rust",
"repo": "nsmryan/rgep",
"path": "/src/ops.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load_a() -> Sym<f64, InstrState> {
let f: Rc<dyn Fn(&mut Vec<f64>, &mut InstrState)> =
Rc::new(move |stack: &mut Vec<f64>, state: &mut InstrState| {
stack.push(state.reg_a);
});
Sym { name: "la".to_string(), arity: Arity::new(0, 1), fun: f }
}
pub fn store_b... | code_fim | hard | {
"lang": "rust",
"repo": "nsmryan/rgep",
"path": "/src/ops.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nsmryan/rgep path: /src/ops.rs
use std::rc::Rc;
use domains::symbols::*;
use domains::stack::push_context;
use domains::tree::Node;
pub fn push_context_sym<A: Copy + 'static>() -> Sym<A, A> {
Sym::new("x".to_string(), Arity::new(0, 2), Rc::new(push_context))
}
pub fn symbol_sy... | code_fim | hard | {
"lang": "rust",
"repo": "nsmryan/rgep",
"path": "/src/ops.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "nogc")]
pub const SELECTED_CONSTRAINTS: PlanConstraints = mmtk::plan::nogc::NOGC_CONSTRAINTS;
#[cfg(feature = "semispace")]
pub const SELECTED_CONSTRAINTS: PlanConstraints = mmtk::plan::semispace::SS_CONSTRAINTS;
#[cfg(feature = "marksweep")]
pub const SELECTED_CONSTRAINTS: PlanConstraint... | code_fim | hard | {
"lang": "rust",
"repo": "PDFxy/mmtk-jikesrvm",
"path": "/mmtk/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
pub fn test2(input1: usize, input2: usize) -> usize {
unsafe {
jtoc_call!(TEST2_METHOD_OFFSET, BOOT_THREAD, input1, input2)
}
}
#[inline(always)]
pub fn test3(input1: usize, input2: usize, input3: usize, input4: usize) -> usize {
u... | code_fim | hard | {
"lang": "rust",
"repo": "PDFxy/mmtk-jikesrvm",
"path": "/mmtk/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PDFxy/mmtk-jikesrvm path: /mmtk/src/lib.rs
#![feature(llvm_asm)]
#![feature(vec_into_raw_parts)]
#[macro_use]
extern crate mmtk;
extern crate libc;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
use mmtk::util::address::Address;
use mmtk::TraceLocal;
use mmtk::vm::VMBindi... | code_fim | hard | {
"lang": "rust",
"repo": "PDFxy/mmtk-jikesrvm",
"path": "/mmtk/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Remove the padding
let padding = bytes.last().unwrap().clone();
let (main, _) = bytes.split_at(block_size - (padding as usize));
String::from_utf8(Vec::from(main)).unwrap()
}<|fim_prefix|>// repo: SLMT/rust-examples path: /padding-oracle-attack/src/pkcs7.rs
use data::Block;
us... | code_fim | hard | {
"lang": "rust",
"repo": "SLMT/rust-examples",
"path": "/padding-oracle-attack/src/pkcs7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SLMT/rust-examples path: /padding-oracle-attack/src/pkcs7.rs
use data::Block;
use data::Message;
pub fn add_padding(s: &str, block_size: usize) -> Message {
let mut message: Message = Vec::new();
let bytes = s.bytes().collect::<Vec<u8>>();
<|fim_suffix|> // Add padding
... | code_fim | hard | {
"lang": "rust",
"repo": "SLMT/rust-examples",
"path": "/padding-oracle-attack/src/pkcs7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _unused = "abc"; //no warning because of leading underscore
}<|fim_prefix|>// repo: jeroenpelgrims/rust-by-example path: /4/variables.rs
fn main() {
let i = 1u;
let b = true;
let unit = ();
let copied_i = i;
<|fim_middle|> println!("{}", copied_i);
println!("{}", b);
println!("{}", un... | code_fim | medium | {
"lang": "rust",
"repo": "jeroenpelgrims/rust-by-example",
"path": "/4/variables.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeroenpelgrims/rust-by-example path: /4/variables.rs
fn main() {
let i = 1u;
let b = true;
let unit = ();
let copied_i = i;
<|fim_suffix|> let _unused = "abc"; //no warning because of leading underscore
}<|fim_middle|> println!("{}", copied_i);
println!("{}", b);
println!("{}", un... | code_fim | medium | {
"lang": "rust",
"repo": "jeroenpelgrims/rust-by-example",
"path": "/4/variables.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> env::set_var("RUST_LOG", "info");
exonum::crypto::init();
helpers::init_logger().unwrap();
let node = NodeBuilder::new()
.with_service(Box::new(configuration::ServiceFactory))
.with_service(Box::new(cryptocurrency::ServiceFactory))
.with_service(Box::new(TimeServic... | code_fim | medium | {
"lang": "rust",
"repo": "rust-chainblock/fashionblockchain",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-chainblock/fashionblockchain path: /src/main.rs
extern crate exonum;
extern crate exonum_configuration;
extern crate node;
extern crate exonum_time;
<|fim_suffix|>fn main() {
env::set_var("RUST_LOG", "info");
exonum::crypto::init();
helpers::init_logger().unwrap();
let nod... | code_fim | medium | {
"lang": "rust",
"repo": "rust-chainblock/fashionblockchain",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FelixMeyr/dico-chain path: /pallets/dao/src/weights.rs
// This file is part of DICO.
// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complia... | code_fim | hard | {
"lang": "rust",
"repo": "FelixMeyr/dico-chain",
"path": "/pallets/dao/src/weights.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (57_051_000 as Weight)
.saturating_add((220_000 as Weight).saturating_mul(m as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn close_early_disapproved(m: u32, p: u32) -> Weight {
(61_406_000 as Weight)
.satu... | code_fim | hard | {
"lang": "rust",
"repo": "FelixMeyr/dico-chain",
"path": "/pallets/dao/src/weights.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rkanati/breakout path: /src/main.rs
mod block;
mod collider;
mod dilate;
mod game;
mod math;
use {
crate::{
block::Block,
dilate::Dilate,
math::*,
},
ggez::{
self,
event, graphics, input::keyboard, timer,
Context, GameResult,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "rkanati/breakout",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let serve = keyboard::is_key_pressed(ctx, KEY_SERVE);
let input = game::Input { paddle_dir, serve };
while timer::check_update_time(ctx, FRAMERATE) {
if !self.state.update(DT, input) {
event::quit(ctx);
break;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rkanati/breakout",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn pickup_sprite(&self, kind: game::PickupKind) -> Sprite {
use game::PickupKind::*;
match kind {
Bonus(amount) => bonus_sprite(amount),
ExtraBall => self.heart,
Detonator => Sprite::new(15., 0., [1.0, 0.0, 0.0, 1.].into()),
MultiBall => ... | code_fim | hard | {
"lang": "rust",
"repo": "rkanati/breakout",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arturkow2000/pxeserver path: /src/tftp/pathutils.rs
use std::path::{Component, Path};
use std::{iter, path::PathBuf};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("found forbidden character \"{ch}\" at {index}")]
ForbiddenCharFound { ch: char, index: usize },
... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/pxeserver",
"path": "/src/tftp/pathutils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = |c: char| -> u8 {
match c {
'0'..='9' => c as u8 - '0' as u8,
'a'..='z' => c as u8 - 'a' as u8 + 10,
'A'..='Z' => c as u8 - 'A' as u8 + 10,
// already verified by is_hex_digit
_ => unreachable!(),
}
};
(c(chs[... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/pxeserver",
"path": "/src/tftp/pathutils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skade/nom path: /src/map.rs
ete(*i),
&Done((), o) => match f(o) {
Error(ref e) => Error(*e),
Incomplete(Needed::Unknown) => Incomplete(Needed::Unknown),
Incomplete(Needed::Size(ref i2)) => Incomplete(Needed::Size(*i2)),
Done(i2,... | code_fim | hard | {
"lang": "rust",
"repo": "skade/nom",
"path": "/src/map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a,'z,R,T> Functor<&'a [R], (), T> for IResult<&'a [R],()> {
#[allow(unused_variables)]
fn map<'y,F: Fn(()) -> T>(&self, f: F) -> IResult<&'a [R],T> {
match self {
&Error(ref e) => Error(*e),
&Incomplete(Needed::Unknown) => Incomplete(Needed::Unknown),
&Incomplete(Needed::Si... | code_fim | hard | {
"lang": "rust",
"repo": "skade/nom",
"path": "/src/map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skade/nom path: /src/map.rs
eded::Unknown),
&Incomplete(Needed::Size(ref i)) => Incomplete(Needed::Size(*i)),//Incomplete(*i),
&Done((), o) => match f(o) {
Error(ref e) => Error(*e),
Incomplete(Needed::Unknown) => Incomplete(Needed::Unknown),
... | code_fim | hard | {
"lang": "rust",
"repo": "skade/nom",
"path": "/src/map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // NOTE(unsafe) static variable initialization
let neighbor_cache = unsafe {
static mut CACHE_ENTRIES: [Option<(IpAddress, Neighbor)>; 8] = [None; 8];
NeighborCache::new(&mut CACHE_ENTRIES[..])
};
// NOTE(unsafe) initialization of MaybeUninit static variable
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "plorefice/datalogger",
"path": "/src/network.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plorefice/datalogger path: /src/network.rs
use crate::time::Instant;
use core::mem::MaybeUninit;
use smolapps::{
net::socket::{
RawPacketMetadata, RawSocketBuffer, SocketHandle, SocketSet, SocketSetItem,
UdpPacketMetadata, UdpSocket, UdpSocketBuffer,
},
net::wire::{Et... | code_fim | hard | {
"lang": "rust",
"repo": "plorefice/datalogger",
"path": "/src/network.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> EthernetInterfaceBuilder::new(eth)
.ethernet_addr(EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]))
.neighbor_cache(neighbor_cache)
.ip_addrs(unsafe { &mut (*IP_ADDRESS.as_mut_ptr())[..] })
.routes(routes)
.finalize()
}
/// Spawns a DHCP client.
fn setup_d... | code_fim | hard | {
"lang": "rust",
"repo": "plorefice/datalogger",
"path": "/src/network.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: odidev/advent-of-code path: /crates/core/src/year2019/day08.rs
21212012222212222120202201211121221202201222222120000022212202220200212122221122201220222222212222221212202212000001022120122022202202022121110102222001212100220212120222210222220101220222001220212221110022202202220200202200022120202... | code_fim | hard | {
"lang": "rust",
"repo": "odidev/advent-of-code",
"path": "/crates/core/src/year2019/day08.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>120212212122211120221022221102000122221110200221211021222022011122222211112200212112222202120221222202112112012222111212222221222100220020022222002011020220222102200220221220220011120012022211020022220222122022222121022011222200102122222202020220202202002001122212100122222221220202221220022202212210120220... | code_fim | hard | {
"lang": "rust",
"repo": "odidev/advent-of-code",
"path": "/crates/core/src/year2019/day08.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>222122222220212222220222222222022222222001222222202122222222022202222212222022222220221202222222202202222222221022222222222212222212122022222122202122222020222222222222121222222022122222222121222222212022222220222212222202222122022212222202222222212102022202221022222222022222220202002022221022202222202120... | code_fim | hard | {
"lang": "rust",
"repo": "odidev/advent-of-code",
"path": "/crates/core/src/year2019/day08.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_attribute_internals(meta_list: &MetaList) -> Result<FieldConstructor> {
let mut tokens_iter = meta_list.tokens.clone().into_iter();
let token = tokens_iter.next().ok_or_else(|| {
let msg = format!("#[{ARBITRARY_ATTRIBUTE_NAME}] cannot be empty.");
syn::Error::new(meta_list... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/derive_arbitrary/src/field_attributes.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/derive_arbitrary/src/field_attributes.rs
use crate::ARBITRARY_ATTRIBUTE_NAME;
use proc_macro2::{Span, TokenStream, TokenTree};
use quote::quote;
use syn::{spanned::Spanned, *};
/// Determines how a value for a field should be constructed.
#[cfg_attr(tes... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla/gecko-dev",
"path": "/third_party/rust/derive_arbitrary/src/field_attributes.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Result: {}", result.unwrap() + 1);
}<|fim_prefix|>// repo: igor-couto/peek-in-pi path: /src/main.rs
mod input;
mod pi;
mod search;
fn main() {
<|fim_middle|> let number_to_search = input::get_player_input();
let file_content = pi::open_one_million_file().expect("Fail to read the pi... | code_fim | hard | {
"lang": "rust",
"repo": "igor-couto/peek-in-pi",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let number_to_search_bytes = number_to_search.as_bytes();
let pi_bytes = file_content.as_bytes();
let result = search::naive_brute_force_search(&number_to_search_bytes, &pi_bytes);
println!("Result: {}", result.unwrap() + 1);
}<|fim_prefix|>// repo: igor-couto/peek-in-pi path: /src/main... | code_fim | medium | {
"lang": "rust",
"repo": "igor-couto/peek-in-pi",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: igor-couto/peek-in-pi path: /src/main.rs
mod input;
mod pi;
mod search;
fn main() {
<|fim_suffix|> let result = search::naive_brute_force_search(&number_to_search_bytes, &pi_bytes);
println!("Result: {}", result.unwrap() + 1);
}<|fim_middle|> let number_to_search = input::get_player_... | code_fim | hard | {
"lang": "rust",
"repo": "igor-couto/peek-in-pi",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>!= 0) && (num % x == 0)))
.sum()
}<|fim_prefix|>// repo: mattjperez/exercism path: /rust/sum-of-multiples/src/lib.rs
pub fn sum_of_multiples(limit: u32, factor<|fim_middle|>s: &[u32]) -> u32 {
(1..limit)
.filter(|num| factors.iter().any(|&x| (x | code_fim | medium | {
"lang": "rust",
"repo": "mattjperez/exercism",
"path": "/rust/sum-of-multiples/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattjperez/exercism path: /rust/sum-of-multiples/src/lib.rs
pub fn sum_of_multiples(limit: u32, factor<|fim_suffix|>!= 0) && (num % x == 0)))
.sum()
}<|fim_middle|>s: &[u32]) -> u32 {
(1..limit)
.filter(|num| factors.iter().any(|&x| (x | code_fim | medium | {
"lang": "rust",
"repo": "mattjperez/exercism",
"path": "/rust/sum-of-multiples/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rv32m1-rust/rv32m1_ri5cy-pac path: /src/emvsim0/rx_status.rs
alse => CRC_OK_A::CRC_OK_0,
true => CRC_OK_A::CRC_OK_1,
}
}
#[doc = "Checks if the value of the field is `CRC_OK_0`"]
#[inline(always)]
pub fn is_crc_ok_0(&self) -> bool {
*self == CRC_OK_A::CRC_OK_0
}
#[doc =... | code_fim | hard | {
"lang": "rust",
"repo": "rv32m1-rust/rv32m1_ri5cy-pac",
"path": "/src/emvsim0/rx_status.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match variant {
PEF_A::PEF_0 => false,
PEF_A::PEF_1 => true,
}
}
}
#[doc = "Reader of field `PEF`"]
pub type PEF_R = crate::R<bool, PEF_A>;
impl PEF_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PEF_A {
match self.bits {
fals... | code_fim | hard | {
"lang": "rust",
"repo": "rv32m1-rust/rv32m1_ri5cy-pac",
"path": "/src/emvsim0/rx_status.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ma1ko/rayon-adaptive path: /src/bin/fully_adaptive.rs
#[cfg(feature = "logs")]
extern crate rayon_logs as rayon;
use rayon_adaptive::fuse_slices;
use rayon_adaptive::prelude::*;
use std::iter::repeat;
const SIZE: usize = 1_000_000;
fn main() {
(1..=4).for_each(|number_of_threads| {
... | code_fim | hard | {
"lang": "rust",
"repo": "ma1ko/rayon-adaptive",
"path": "/src/bin/fully_adaptive.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>us| fuse_slices(previous, slice))
.or_else(move || Some(slice))
},
)
.helping_cutting_fold(
1.0,
|last_elem_prev_slice, slice| {
slice.iter_mut().fold(last_elem_p... | code_fim | hard | {
"lang": "rust",
"repo": "ma1ko/rayon-adaptive",
"path": "/src/bin/fully_adaptive.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arma3modorganizer/SQM_Parser path: /src/lib.rs
#![allow(
clippy::missing_docs_in_private_items,
clippy::missing_inline_in_public_items,
clippy::implicit_return,
clippy::result_unwrap_used,
clippy::option_unwrap_used,
clippy::print_stdout,
clippy::use_debug,
clippy::integer_arithmetic,
clippy::de... | code_fim | hard | {
"lang": "rust",
"repo": "arma3modorganizer/SQM_Parser",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
pub fn parse_class(item: Pair<Rule>) -> (String, Class) {
let inner = item.into_inner();
let mut retclass: Class = Class{
items: Default::default(),
arrays: Default::default(),
classes: Default::default()
};
let mut key: String = "".to_string();
for i... | code_fim | hard | {
"lang": "rust",
"repo": "arma3modorganizer/SQM_Parser",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> filedata.walk(&file);
}
#[inline]
pub fn parse_file(filedata: Pairs<Rule>) -> File{
let file = filedata.enumerate().nth(0).unwrap().1.into_inner();
let mut file_strc: File = File{
items: Default::default(),
arrays: Default::default(),
classes: Default::default()
... | code_fim | hard | {
"lang": "rust",
"repo": "arma3modorganizer/SQM_Parser",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match config
.signer_private_key_path
.as_ref()
.unwrap()
.extension()
.unwrap()
.to_str()
.unwrap()
{
"der" => pkey = PKey::private_key_from_der(&pkey_bytes).unwrap(),
"pem" => pkey = PKey::private_key_from_pem(&pkey_bytes).u... | code_fim | hard | {
"lang": "rust",
"repo": "verypossible/tls-credential-helper",
"path": "/src/crypto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: verypossible/tls-credential-helper path: /src/crypto.rs
use std::fs;
use std::path::PathBuf;
use strum_macros::Display;
use openssl::asn1::Asn1Time;
use openssl::bn::{BigNum, MsbOption};
use openssl::ec::*;
use openssl::error::ErrorStack;
use openssl::hash::MessageDigest;
use openssl::pkey::{PK... | code_fim | hard | {
"lang": "rust",
"repo": "verypossible/tls-credential-helper",
"path": "/src/crypto.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pkey: PKey<Private>;
match config
.signer_private_key_path
.as_ref()
.unwrap()
.extension()
.unwrap()
.to_str()
.unwrap()
{
"der" => pkey = PKey::private_key_from_der(&pkey_bytes).unwrap(),
"pem" => pkey = PKey::priva... | code_fim | hard | {
"lang": "rust",
"repo": "verypossible/tls-credential-helper",
"path": "/src/crypto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod source;
pub mod builder;
pub use types::*;
#[allow(dead_code)]
pub mod rules;
#[allow(dead_code)]
mod types;
#[allow(dead_code)]
pub mod navigation;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: dsp/neweden path: /src/lib.r... | code_fim | medium | {
"lang": "rust",
"repo": "dsp/neweden",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dsp/neweden path: /src/lib.rs
/*
* Copyright (c) 2019. David "Tiran'Sol" Soria Parra
* All rights reserved.
*/
#![cfg_attr(test, feature(test))]
//! neweden is a rust library for system information, wayfinding and
//! range queries for the MMORPG Eve Online from CCP Games.
//!
//! Online data... | code_fim | medium | {
"lang": "rust",
"repo": "dsp/neweden",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
pub mod navigation;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: dsp/neweden path: /src/lib.rs
/*
* Copyright (c) 2019. David "Tiran'Sol" Soria Parra
* All rights reserved.
*/
#![cfg_attr(test, feature(test))]... | code_fim | hard | {
"lang": "rust",
"repo": "dsp/neweden",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cesantaniello/Rust path: /variables/src/main.rs
fn main() {
//let <nombre de la variable> = <El valor>
//let <nombre de la variable>: <Tipo> = <El valor>
//let mut <nombre de la variable> = <El valor>
<|fim_suffix|> println!("EL resultado de ({} + {} + {}) es: {}",
numero_uno... | code_fim | hard | {
"lang": "rust",
"repo": "cesantaniello/Rust",
"path": "/variables/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.