text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> pub fn get_new_process<S>(&self, name: S) -> ProcessHandle
where
S: Into<String>,
{
let pid = self.new_process(name).expect("creation failed");
self.get_process(pid).expect("get failed")
}
pub fn visualizer_droplet_info(&self) -> PuddleResult<Vec<DropletInfo>> ... | code_fim | hard | {
"lang": "rust",
"repo": "Immortalin/puddle",
"path": "/puddle-core/src/process/manager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Manager {
pub fn new(blocking: bool, grid: Grid) -> Manager {
let system = Arc::new(Mutex::new(System::new(grid)));
Manager {
system,
blocking,
processes: Mutex::new(IndexMap::default()),
}
}
pub fn get_logs(&self) -> Vec<crate... | code_fim | hard | {
"lang": "rust",
"repo": "Immortalin/puddle",
"path": "/puddle-core/src/process/manager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: derekchiang/CS5412 path: /src/examples/fail_counter.rs
extern crate paxos;
use paxos::StateMachine;
use paxos::Command;
struct Counter {
counter: uint
}
impl StateMachine<~str> for Counter {
fn new() -> Counter {
return Counter {
counter: 0
}
}
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "derekchiang/CS5412",
"path": "/src/examples/fail_counter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> _ => {
res_tx.send(~"unexpected");
}
}
}
}
fn main() {
let cluster = paxos::new_cluster::<~str, Counter>();
let mut client = cluster.new_client(7u64 << 32);
for i in range(0, 10) {
client.call(~"inc", vec!(~"1")).recv();
... | code_fim | hard | {
"lang": "rust",
"repo": "derekchiang/CS5412",
"path": "/src/examples/fail_counter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = vec![BlsScalar::zero(), BlsScalar::one()];
let s = Polynomial::from_coefficients_vec(s);
let tempp = s.coeffs[1].to_bytes();
for i in 0..32 {
let temp = tempp[i];
println!("{}", temp)
}
let length = 2 as usize;
let domain = EvaluationDomain::new(length)... | code_fim | hard | {
"lang": "rust",
"repo": "LiraWang/halo09",
"path": "/src/lagrange_interpolation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiraWang/halo09 path: /src/lagrange_interpolation.rs
///This code can compute the interpolation polynomial for a given vector as well as compute its dual
/// vector which can be used in halo 0.9. Moreover, the fast computation of inner product <s, r> can
/// also be calculated.
use crate::commit... | code_fim | hard | {
"lang": "rust",
"repo": "LiraWang/halo09",
"path": "/src/lagrange_interpolation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match format {
ArchiveFormat::Zip => {
let path = std::path::Path::new(archive);
let file = fs::File::open(&path).unwrap();
let mut archive = zip::ZipArchive::new(file).unwrap();
for i in 0..archive.len() {
let mut file = archive.... | code_fim | hard | {
"lang": "rust",
"repo": "isacsund/tap",
"path": "/src/cmd/extract.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (&*file.name()).ends_with('/') {
fs::create_dir_all(&outpath).unwrap();
} else {
log::debug!(
"File {} extracted to \"{}\"",
i,
outpath.as_path().display()
... | code_fim | hard | {
"lang": "rust",
"repo": "isacsund/tap",
"path": "/src/cmd/extract.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isacsund/tap path: /src/cmd/extract.rs
use crate::archive::ArchiveFormat;
use anyhow::Result;
use clap::{App, Arg, ArgMatches, SubCommand};
use std::{fs, io, str};
pub const COMMAND_NAME: &str = "extract";
pub fn command() -> App<'static, 'static> {
SubCommand::with_name(COMMAND_NAME)
... | code_fim | hard | {
"lang": "rust",
"repo": "isacsund/tap",
"path": "/src/cmd/extract.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaddyshad/xml-parser path: /src/tree_builder/stack.rs
use std::collections::VecDeque;
/// Token processor stack structure
#[derive(Debug)]
pub struct Stack<T> {
stack: VecDeque<T>,
}
impl<T> Stack<T> {
pub fn new() -> Stack<T> {
Stack {
stack: VecDeque::new(),
... | code_fim | hard | {
"lang": "rust",
"repo": "shaddyshad/xml-parser",
"path": "/src/tree_builder/stack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //top of the stack
pub fn top(&self) -> Option<&T> {
self.stack.front()
}
}<|fim_prefix|>// repo: shaddyshad/xml-parser path: /src/tree_builder/stack.rs
use std::collections::VecDeque;
/// Token processor stack structure
#[derive(Debug)]
pub struct Stack<T> {
stack: VecDeque<T>,... | code_fim | medium | {
"lang": "rust",
"repo": "shaddyshad/xml-parser",
"path": "/src/tree_builder/stack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>re code
pub use client::KvsClient;
pub use engine::{KvStore, KvsEngine};
pub use error::{KvsError, Result};
pub use server::KvsServer;<|fim_prefix|>// repo: Ted-Jiang/rust-kv path: /src/lib.rs
mod kv;
mod error;
mod client;
mod server;
mod common;
mod engine;
<|fim_middle|>pub mod thread_pool;
// why ne... | code_fim | medium | {
"lang": "rust",
"repo": "Ted-Jiang/rust-kv",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ine};
pub use error::{KvsError, Result};
pub use server::KvsServer;<|fim_prefix|>// repo: Ted-Jiang/rust-kv path: /src/lib.rs
mod kv;
mod error;
mod client;
mod server;
mod common;
mod engine;
pub mod thread_pool;
// why need this? because lib need define sha<|fim_middle|>re code
pub use client::KvsClie... | code_fim | medium | {
"lang": "rust",
"repo": "Ted-Jiang/rust-kv",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ted-Jiang/rust-kv path: /src/lib.rs
mod kv;
mod error;
mod client;
mod server;
mod common;
mod engine;
pub mod thread_pool;
// why need this? because lib need define sha<|fim_suffix|>ine};
pub use error::{KvsError, Result};
pub use server::KvsServer;<|fim_middle|>re code
pub use client::KvsClie... | code_fim | medium | {
"lang": "rust",
"repo": "Ted-Jiang/rust-kv",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ThoFrank/mvg path: /mvg_lib/src/lib.rs
pub mod data;
mod query;
#[cfg(test)]
mod test;
use hyper::{body::HttpBody as _, client::HttpConnector, Client};
use hyper_tls::HttpsConnector;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use data::{MVGError};
use data::location::{Loca... | code_fim | hard | {
"lang": "rust",
"repo": "ThoFrank/mvg",
"path": "/mvg_lib/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = self.client.get(url).await?;
if res.status() != http::status::StatusCode::OK {
return Err(MVGError::ArgumentError(
format!("No valid station id: {}", station_id)
));
}
let mut json = String::new();
while let Som... | code_fim | hard | {
"lang": "rust",
"repo": "ThoFrank/mvg",
"path": "/mvg_lib/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parallaxsecond/parsec-client-rust path: /src/core/basic_client.rs
::InvalidServiceResponseType))
}
}
/// **[Cryptographic Operation]** Create an asymmetric signature on a pre-computed message digest.
///
/// The key intended for signing **must** have its `sign_hash` flag... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/parsec-client-rust",
"path": "/src/core/basic_client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let op = PrepareKeyAttestation::ActivateCredential {
attested_key_name,
attesting_key_name,
};
let res = self.op_client.process_operation(
NativeOperation::PrepareKeyAttestation(op),
ProviderId::Tpm,
&self.auth_data,
... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/parsec-client-rust",
"path": "/src/core/basic_client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parallaxsecond/parsec-client-rust path: /src/core/basic_client.rs
ntication data \"{:?}\"", client.implicit_provider(), client.auth_data());
Ok(client)
}
/// Create a client that can initially only be used with Core operations not necessitating
/// authentication (eg ping).
... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/parsec-client-rust",
"path": "/src/core/basic_client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erszcz/learning path: /rust-channels/multiecho.rs
#![feature(phase, slicing_syntax)]
#[phase(plugin, link)] extern crate log;
use std::str;
use std::io::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener};
fn main() {
let addr = "127.0.1.1";
let port = 9100;
let listener = ... | code_fim | medium | {
"lang": "rust",
"repo": "erszcz/learning",
"path": "/rust-channels/multiecho.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("echoing {} to {}", str::from_utf8(buf).unwrap().trim(),
stream.peer_name().unwrap());
match stream.write(buf) {
Err (e) => fail!("TCP write error: {}", e),
Ok (()) => ()
}
}<|fim_prefix|>// repo: erszcz/learning path: /rust-channels/multiecho.rs
#![feature(p... | code_fim | hard | {
"lang": "rust",
"repo": "erszcz/learning",
"path": "/rust-channels/multiecho.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The pubkey sets should be identical
assert_eq!(pubs0, pubs1);
assert_eq!(pubs1, pubs2);
// Two sigs should be enough to sign a message
let msg = "signed message";
let sig_shares: BTreeMap<usize, SignatureShare> =
BTreeMap::from([(0, sec0.sign... | code_fim | hard | {
"lang": "rust",
"repo": "maidsafe/sn_sdkg",
"path": "/src/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maidsafe/sn_sdkg path: /src/state.rs
onBecauseMissingAcks)
));
// Now that every participant handled the Parts and submitted their Acks, we handle the Acks
// Participant 0 handles Acks
let _ = &dkg_state0.handle_signed_vote(acks1.clone(), &mut rng);
// ... | code_fim | hard | {
"lang": "rust",
"repo": "maidsafe/sn_sdkg",
"path": "/src/state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marius851000/bch3ds path: /src/model/header.rs
use crate::deserialize::{
read_matrix4x3_f32_le, read_referenced_null_terminated_ascii_string, read_u16_le, read_u32_le,
read_u8,
};
use crate::{ReferenceDict, ReferenceDictError};
use std::io;
use std::io::{Read, Seek, SeekFrom};
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "marius851000/bch3ds",
"path": "/src/model/header.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let object_node_count = read_u32_le(file).map_err(|e| ioe(e, "object node count"))?;
let model_name = read_referenced_null_terminated_ascii_string(file)
.map_err(|e| ioe(e, "model name"))?
.ok_or(ModelHeaderError::NullPointerToName)?;
let object_node_name_... | code_fim | hard | {
"lang": "rust",
"repo": "marius851000/bch3ds",
"path": "/src/model/header.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn should_serve_deploy_accepted_events_with_query() {
should_serve_events_with_query(DEPLOYS_PATH).await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn should_serve_signature_events_with_query() {
should_se... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/node/src/components/event_stream_server/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn should_handle_wrapping_past_max_event_id_for_deploy_accepted() {
should_handle_wrapping_past_max_event_id(DEPLOYS_PATH).await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn should_handle_wrapping_past_max_ev... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/node/src/components/event_stream_server/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /node/src/components/event_stream_server/tests.rs
}
let data = match event {
SseData::DeployAccepted {
deploy: deploy_hash,
} => {
let deploy_accepted = self.dep... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/node/src/components/event_stream_server/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let env = Environment::new("/home/jrowe7/slf/jinja2-c/test_template");
env.list_templates();
let tmpl = env.get_template("index.html");
let mut vars = HashMap::new();
vars.insert("name".to_owned(), "James".to_owned());
println!("{}", tmpl.render(Some(vars)).expect("Render failed?")... | code_fim | easy | {
"lang": "rust",
"repo": "jroweboy/jinja2-c",
"path": "/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jroweboy/jinja2-c path: /test.rs
extern crate rustjinja2;
extern crate collections;
<|fim_suffix|>fn main() {
let env = Environment::new("/home/jrowe7/slf/jinja2-c/test_template");
env.list_templates();
let tmpl = env.get_template("index.html");
let mut vars = HashMap::new();
... | code_fim | easy | {
"lang": "rust",
"repo": "jroweboy/jinja2-c",
"path": "/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tools::copy_from_vec(&mut header, vec, 0, 3);
tools::copy_from_vec(&mut artist, vec, size - 95, 30);
tools::copy_from_vec(&mut album, vec, size - 65, 30);
tools::copy_from_vec(&mut title, vec, size - 125, 30);
self.id3 = String::from_utf8(header.iter().cloned().col... | code_fim | hard | {
"lang": "rust",
"repo": "stan4cb/rust-tools",
"path": "/src/id3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.artist = String::from_utf8(artist.iter().cloned().collect()).unwrap();
self.album = String::from_utf8(album.iter().cloned().collect()).unwrap();
self.title = String::from_utf8(title.iter().cloned().collect()).unwrap();
}
pub fn is_id3(&self) -> bool {
self.id3... | code_fim | hard | {
"lang": "rust",
"repo": "stan4cb/rust-tools",
"path": "/src/id3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stan4cb/rust-tools path: /src/id3.rs
use tools;
use std::fs::*;
use std::io::Write;
#[allow(dead_code)]
pub struct ID3 {
pub id3: bool,
pub version: (u8, u8),
pub artist: String,
pub album: String,
pub title: String,
pub track: u8,
pub folder_name: String,
}
#[a... | code_fim | hard | {
"lang": "rust",
"repo": "stan4cb/rust-tools",
"path": "/src/id3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: storiqaamericanteam/stores path: /src/repos/categories/mod.rs
n create(&self, payload: NewCategory) -> RepoResult<Category> {
debug!("Create new category {:?}.", payload);
self.cache.remove();
let new_category_level = if payload.parent_id == CategoryId(0) {
O... | code_fim | hard | {
"lang": "rust",
"repo": "storiqaamericanteam/stores",
"path": "/src/repos/categories/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: storiqaamericanteam/stores path: /src/repos/categories/mod.rs
diesel::update(categories)
.set(level.eq(level_arg))
.filter(id.eq(id_arg))
.execute(self.db_conn)?;
}
Ok(())
})
}
}
impl<'a... | code_fim | hard | {
"lang": "rust",
"repo": "storiqaamericanteam/stores",
"path": "/src/repos/categories/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cat = Category::default();
cat.id = CategoryId(1);
for i in 2..4 {
let mut cat_child = Category::default();
cat_child.id = CategoryId(i);
cat_child.parent_id = Some(CategoryId(1));
for j in 1..3 {
let mut cat_c... | code_fim | hard | {
"lang": "rust",
"repo": "storiqaamericanteam/stores",
"path": "/src/repos/categories/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Tuple implementations allows multiple hooks to compose a pipeline
impl<A, B, In, OA, OB, Repository, Error> Hook<Repository> for (A, B)
where
A: Hook<Repository, Input = In, Output = OA, Error = Error>,
B: Hook<Repository, Input = OA, Output = OB, Error = Error>,
{
type Input = In;
typ... | code_fim | medium | {
"lang": "rust",
"repo": "AlisCode/db_api",
"path": "/db_api/src/hooks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlisCode/db_api path: /db_api/src/hooks.rs
/// A Hook is an element of the pipeline that is going to be applied
/// to a route in a repository.
pub trait Hook<Repository> {
type Input;
type Output;
type Error;
fn handle(
<|fim_suffix|>/// Tuple implementations allows multiple ho... | code_fim | medium | {
"lang": "rust",
"repo": "AlisCode/db_api",
"path": "/db_api/src/hooks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiegec/verilog-lang path: /src/ast/source_text/module_parameters_ports.rs
//! A.1.3 Module parameters and ports
use crate::ast::*;
/// list_of_port_declarations ::= ( [ { attribute_instance } ansi_port_declaration { , { attribute_instance } ansi_port_declaration } ] )
#[derive(PartialEq, Eq, Cl... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/verilog-lang",
"path": "/src/ast/source_text/module_parameters_ports.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Parse for PortDirection {
fn parse(parser: &mut Parser<'_>) -> Option<Self> {
if let Some(token) = parser.peek() {
let res = match token.token {
Token::Input => Some(PortDirection::Input),
Token::Output => Some(PortDirection::Output),
... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/verilog-lang",
"path": "/src/ast/source_text/module_parameters_ports.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/45814.rs
#![feature(specialization)]
pub trait Trait<T> { }
<|fim_suffix|>impl<T> Trait<<T as Iterator>::Item> for T { }
fn main() { }<|fim_middle|>default impl<T, U> Trait<T> for U { }
| code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/45814.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> Trait<<T as Iterator>::Item> for T { }
fn main() { }<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/45814.rs
#![feature(specialization)]
<|fim_middle|>pub trait Trait<T> { }
default impl<T, U> Trait<T> for U { }
| code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/45814.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some((bytes.len() / mem::size_of::<u32>()) as u64)
}
}<|fim_prefix|>// repo: palfrey/milli path: /milli/src/heed_codec/roaring_bitmap_length/bo_roaring_bitmap_len_codec.rs
use std::mem;
pub struct BoRoaringBitmapLenCodec;
<|fim_middle|>impl heed::BytesDecode<'_> for BoRoaringBitmapLenCodec ... | code_fim | medium | {
"lang": "rust",
"repo": "palfrey/milli",
"path": "/milli/src/heed_codec/roaring_bitmap_length/bo_roaring_bitmap_len_codec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: palfrey/milli path: /milli/src/heed_codec/roaring_bitmap_length/bo_roaring_bitmap_len_codec.rs
use std::mem;
pub struct BoRoaringBitmapLenCodec;
<|fim_suffix|> fn bytes_decode(bytes: &[u8]) -> Option<Self::DItem> {
Some((bytes.len() / mem::size_of::<u32>()) as u64)
}
}<|fim_midd... | code_fim | medium | {
"lang": "rust",
"repo": "palfrey/milli",
"path": "/milli/src/heed_codec/roaring_bitmap_length/bo_roaring_bitmap_len_codec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f427/fsmc/pmem4.rs
#[doc = "Register `PMEM4` reader"]
pub struct R(crate::R<PMEM4_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<PMEM4_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Tar... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f427/fsmc/pmem4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `MEMWAIT` writer - MEMWAITx"]
pub struct MEMWAIT_W<'a> {
w: &'a mut W,
}
impl<'a> MEMWAIT_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0xff... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f427/fsmc/pmem4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewGi/Virtual-Hid path: /src/packet/connection.rs
use crate::packet::Packet;
use futures_util::SinkExt;
use std::io;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
use tokio::net::TcpStream;
use tokio::sync::{
mps... | code_fim | medium | {
"lang": "rust",
"repo": "AndrewGi/Virtual-Hid",
"path": "/src/packet/connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>type Decoder = LengthDelimitedCodec;
pub fn spawn_framed(
read: impl AsyncRead + Unpin + 'static,
write: impl AsyncWrite + Unpin + 'static,
) -> (UnboundedSender<Bytes>, UnboundedReceiver<BytesMut>) {
let mut read = FramedRead::new(read, Decoder::new());
let mut write = FramedWrite::new(w... | code_fim | medium | {
"lang": "rust",
"repo": "AndrewGi/Virtual-Hid",
"path": "/src/packet/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn spawn_framed(
read: impl AsyncRead + Unpin + 'static,
write: impl AsyncWrite + Unpin + 'static,
) -> (UnboundedSender<Bytes>, UnboundedReceiver<BytesMut>) {
let mut read = FramedRead::new(read, Decoder::new());
let mut write = FramedWrite::new(write, Decoder::new());
let (tx_sen... | code_fim | medium | {
"lang": "rust",
"repo": "AndrewGi/Virtual-Hid",
"path": "/src/packet/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dop!(buf,"D {} {}",1,2);
dopl!(buf,"E {} {}",1,2);
}<|fim_prefix|>// repo: QuietJoon/StudyRust-Macro path: /src/main.rs
use std::io::*;
use StudyRustMacro::*;
fn main() {
// NOTE: because stdout().lock() is not allowed
let stdout = stdout();
let lock = stdout.lock();
let mut buf ... | code_fim | medium | {
"lang": "rust",
"repo": "QuietJoon/StudyRust-Macro",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fastp!(buf,"A");
fastp!(buf,"B {}",1);
fastp!(buf,"C {} {}",1,2);
dop!(buf,"D {} {}",1,2);
dopl!(buf,"E {} {}",1,2);
}<|fim_prefix|>// repo: QuietJoon/StudyRust-Macro path: /src/main.rs
use std::io::*;
use StudyRustMacro::*;
<|fim_middle|>fn main() {
// NOTE: because stdout().lo... | code_fim | medium | {
"lang": "rust",
"repo": "QuietJoon/StudyRust-Macro",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: QuietJoon/StudyRust-Macro path: /src/main.rs
use std::io::*;
use StudyRustMacro::*;
fn main() {
// NOTE: because stdout().lock() is not allowed
let stdout = stdout();
let lock = stdout.lock();
let mut buf = BufWriter::new(lock);
<|fim_suffix|> dop!(buf,"D {} {}",1,2);
do... | code_fim | medium | {
"lang": "rust",
"repo": "QuietJoon/StudyRust-Macro",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>self
registry
:
&
Registry
token
:
Token
interests
:
Interest
)
/
/
/
-
>
io
:
:
Result
<
(
)
>
/
/
/
{
/
/
/
/
/
Delegate
the
reregister
call
to
socket
/
/
/
self
.
socket
.
reregister
(
registry
token
interests
)
/
/
/
}
/
/
/
/
/
/
fn
deregister
(
&
mut
self
registry
:
&
Registry
)
-
>
io
:
:
Result
<
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/mio/src/event/source.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/mio/src/event/source.rs
use
crate
:
:
{
Interest
Registry
Token
}
;
use
std
:
:
io
;
/
/
/
An
event
source
that
may
be
registered
with
[
Registry
]
.
/
/
/
/
/
/
Types
that
implement
event
:
:
Source
can
be
registered
with
/
/
/
Registry
.
User... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/mio/src/event/source.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: millerjs/modelm path: /src/ffi/linux.rs
/// Linux key handler ffi
use std::fs::File;
use std::io::prelude::*;
use std::sync::mpsc::Sender;
use std::{mem, slice, io, env};
use super::types::{EventType, KeyEvent};
type LinuxEventCode = u16;
type LinuxEventType = u16;
type LinuxEventValue = u32;
... | code_fim | hard | {
"lang": "rust",
"repo": "millerjs/modelm",
"path": "/src/ffi/linux.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Opens the input device, will use MODELM_INPUT_DEVICE environment
/// variable if set
fn open_device() -> Result<File, io::Error> {
let path = env::var("MODELM_INPUT_DEVICE")
.unwrap_or("/dev/input/event0".to_owned());
File::open(path)
}
/// Sends KeyEvents to the channel. Returns onl... | code_fim | hard | {
"lang": "rust",
"repo": "millerjs/modelm",
"path": "/src/ffi/linux.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /compiler/rustc_ty_utils/src/abi.rs
} else {
panic!("expected `ResumeTy`, found `{:?}`", sig.resume_ty);
};
}
let context_mut_ref = Ty::new_task_context(tcx);
(conte... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/compiler/rustc_ty_utils/src/abi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tcx: TyCtxt<'tcx>,
query: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>,
) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> {
let (param_env, (instance, extra_args)) = query.into_parts();
let sig = fn_sig_for_fn_abi(tcx, instance, param_env);
let... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/compiler/rustc_ty_utils/src/abi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /compiler/rustc_ty_utils/src/abi.rs
et ret_ty = Ty::new_adt(tcx, poll_adt_ref, poll_args);
// We have to replace the `ResumeTy` that is used for type and borrow checking
// with `&mut Context<'_>` which is used in codegen.
#[c... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/compiler/rustc_ty_utils/src/abi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn is_error(ready: Ready) -> bool {
UnixReady::from(ready).is_error()
}
}
#[cfg(windows)]
mod sys {
use mio::Ready;
pub(crate) fn hup() -> Ready {
Ready::empty()
}
pub(crate) fn is_hup(_: Ready) -> bool {
false
}
pub(crate) fn error() ... | code_fim | medium | {
"lang": "rust",
"repo": "Darksonn/tokio",
"path": "/tokio/src/runtime/io/platform.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Darksonn/tokio path: /tokio/src/runtime/io/platform.rs
pub(crate) use self::sys::*;
#[cfg(unix)]
mod sys {
use mio::unix::UnixReady;
use mio::Ready;
<|fim_suffix|> pub(crate) fn is_hup(ready: Ready) -> bool {
UnixReady::from(ready).is_hup()
}
pub(crate) fn error() -... | code_fim | medium | {
"lang": "rust",
"repo": "Darksonn/tokio",
"path": "/tokio/src/runtime/io/platform.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn error() -> Ready {
Ready::empty()
}
pub(crate) fn is_error(_: Ready) -> bool {
false
}
}<|fim_prefix|>// repo: Darksonn/tokio path: /tokio/src/runtime/io/platform.rs
pub(crate) use self::sys::*;
#[cfg(unix)]
mod sys {
use mio::unix::UnixReady;
use m... | code_fim | hard | {
"lang": "rust",
"repo": "Darksonn/tokio",
"path": "/tokio/src/runtime/io/platform.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<Source, T> NoiseModule<Point3<T>, T> for ScalePoint<Source, T>
where Source: NoiseModule<Point3<T>, T>,
T: Float,
{
fn get(&self, point: Point3<T>) -> T {
self.source.get([point[0] * self.x_scale, point[1] * self.y_scale, point[2] * self.z_scale])
}
}
impl<Source, T> N... | code_fim | hard | {
"lang": "rust",
"repo": "Ameobea/noise-rs",
"path": "/src/modules/transformers/scale_point.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ameobea/noise-rs path: /src/modules/transformers/scale_point.rs
// Copyright (c) 2017 The Noise-rs 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/licens... | code_fim | hard | {
"lang": "rust",
"repo": "Ameobea/noise-rs",
"path": "/src/modules/transformers/scale_point.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/autocfg-0.1.7/src/tests.rs
use super::AutoCfg;
impl AutoCfg {
fn core_std(&self, path: &str) -> String {
let krate = if self.no_std { "core" } else { "std" };
format!("{}::{}", krate, path)
}
}
#[test]
fn autocfg_version() {
l... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/autocfg-0.1.7/src/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ac = AutoCfg::with_dir("target").unwrap();
assert!(!ac.probe_sysroot_crate("doesnt_exist"));
}
#[test]
fn probe_no_std() {
let ac = AutoCfg::with_dir("target").unwrap();
assert!(ac.probe_type("i32"));
assert!(ac.probe_type("[i32]"));
assert_eq!(ac.probe_type("Vec<i32>"), !ac.n... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/autocfg-0.1.7/src/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Part 1's logic is straightforward: jump if we have to (there's a hole at 1, 2 or 3) and if
// we can (there isn't one at 4).
const PART_1_SCRIPT: &str =
"NOT A J
NOT B T
OR T J
NOT C T
OR T J
AND D J
WALK
";
// Part 2's logic bolts onto that: don't jump unless either we can jump again immediately on
... | code_fim | medium | {
"lang": "rust",
"repo": "ThePants999/advent-of-code-2019",
"path": "/day21/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ThePants999/advent-of-code-2019 path: /day21/src/main.rs
#![allow(clippy::cast_sign_loss)]
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::cast_possible_truncation)]
#![allow(clippy::cast_possible_wrap)]
use std::sync::mpsc;
use intcode;
// Part 1's logic is straightforward: jump if w... | code_fim | hard | {
"lang": "rust",
"repo": "ThePants999/advent-of-code-2019",
"path": "/day21/src/main.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn number_of_mutators() -> usize {
unimplemented!()
}
}
lazy_static! {
pub static ref MUTATOR_ITERATOR_LOCK: Mutex<()> = Mutex::new(());
}<|fim_prefix|>// repo: wangbrenda/mmtk-dotnet path: /mmtk/src/active_plan.rs
use mmtk::{Plan, SelectedPlan};
use mmtk::scheduler::GCWorker;
use mm... | code_fim | hard | {
"lang": "rust",
"repo": "wangbrenda/mmtk-dotnet",
"path": "/mmtk/src/active_plan.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wangbrenda/mmtk-dotnet path: /mmtk/src/active_plan.rs
use mmtk::{Plan, SelectedPlan};
use mmtk::scheduler::GCWorker;
use mmtk::vm::ActivePlan;
use mmtk::util::OpaquePointer;
use DotNET;
use SINGLETON;
use super::UPCALLS;
use std::sync::Mutex;
pub struct VMActivePlan<> {}
impl ActivePlan<DotNET... | code_fim | hard | {
"lang": "rust",
"repo": "wangbrenda/mmtk-dotnet",
"path": "/mmtk/src/active_plan.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rp = ReplicaPlacement {
diff_data_center_count: bytes[0] - '0' as u8,
diff_rack_count: bytes[1] - '0' as u8,
same_rack_count: bytes[2] - '0' as u8,
};
Ok(rp)
}
pub fn string(&self) -> String {
let mut s = String::new();
... | code_fim | medium | {
"lang": "rust",
"repo": "jitendraky/zergling",
"path": "/src/storage/replica_placement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jitendraky/zergling path: /src/storage/replica_placement.rs
use super::Result;
use std::fmt::Write;
use storage::errors::Error::ParseReplicaPlacement;
#[derive(Serialize, Deserialize, Debug, Default, Copy, Clone)]
pub struct ReplicaPlacement {
pub same_rack_count: u8,
pub diff_rack_coun... | code_fim | hard | {
"lang": "rust",
"repo": "jitendraky/zergling",
"path": "/src/storage/replica_placement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(rp)
}
pub fn string(&self) -> String {
let mut s = String::new();
// should never fail
write!(
s,
"{}{}{}",
self.diff_data_center_count,
self.diff_rack_count,
self.same_rack_count
).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "jitendraky/zergling",
"path": "/src/storage/replica_placement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = PI * p / self.length + self.phase;
let sines = f32::sin(x[0]) * f32::sin(x[1]) * f32::sin(x[2]);
if sines < 0.0 {
self.odd.value(uv, p)
} else {
self.even.value(uv, p)
}
}
}<|fim_prefix|>// repo: tttmmmyyyy/ray path: /src/texture... | code_fim | hard | {
"lang": "rust",
"repo": "tttmmmyyyy/ray",
"path": "/src/texture/checker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl CheckerTexture {
pub fn new(even: Arc<Texture>, odd: Arc<Texture>, length: f32, phase: &Vec3) -> Self {
CheckerTexture {
even: even,
odd: odd,
length: length,
phase: *phase,
}
}
}
impl Texture for CheckerTexture {
fn value(&... | code_fim | medium | {
"lang": "rust",
"repo": "tttmmmyyyy/ray",
"path": "/src/texture/checker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tttmmmyyyy/ray path: /src/texture/checker.rs
use crate::aliases::{Vec2, Vec3};
use crate::texture::Texture;
use std::f32::consts::PI;
use std::sync::Arc;
pub struct CheckerTexture {
length: f32,
even: Arc<Texture>,
odd: Arc<Texture>,
phase: Vec3,
}
impl CheckerTexture {
pub... | code_fim | medium | {
"lang": "rust",
"repo": "tttmmmyyyy/ray",
"path": "/src/texture/checker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use data_traits::{ListData, ListDataMut, SingleData, SingleDataMut};
pub use filter::{Filter, FilteredList, SimpleCaseInsensitiveFilter};
pub use list_view::{ListMsg, ListView, SelectionMode};
pub use shared_data::SharedRc;
pub use single_view::SingleView;
pub use view_widget::{CheckBoxView, RadioBoxB... | code_fim | hard | {
"lang": "rust",
"repo": "wiltonlazary/kas",
"path": "/src/widget/view/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod data_traits;
mod filter;
mod list_view;
mod shared_data;
mod single_view;
mod view_widget;
pub use data_traits::{ListData, ListDataMut, SingleData, SingleDataMut};
pub use filter::{Filter, FilteredList, SimpleCaseInsensitiveFilter};
pub use list_view::{ListMsg, ListView, SelectionMode};
pub use share... | code_fim | hard | {
"lang": "rust",
"repo": "wiltonlazary/kas",
"path": "/src/widget/view/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wiltonlazary/kas path: /src/widget/view/mod.rs
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/L... | code_fim | hard | {
"lang": "rust",
"repo": "wiltonlazary/kas",
"path": "/src/widget/view/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CaryWillard/Aether path: /src/envelopes.rs
// Envelopes
use super::{Percent, Seconds, SampleRate};
use super::envelope_forms::EnvelopeForm;
use super::indexers::{DynamicPercentIndexer, UnpitchedIndexer, OptionDynamicPercentIndexer};
pub trait Envelope {
fn get_percent(&mut self) -> Percent... | code_fim | hard | {
"lang": "rust",
"repo": "CaryWillard/Aether",
"path": "/src/envelopes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub struct EnvSeq {
seq: Vec<Env>,
i: usize,
}
impl EnvSeq {
pub fn new(seq: Vec<Env>) -> EnvSeq {
EnvSeq { seq: seq, i: 0 }
}
}
impl OptionEnvelope for EnvSeq {
fn get_percent_option(&mut self) -> Option<Percent> {
loop {
if self.i >= self.seq.len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "CaryWillard/Aether",
"path": "/src/envelopes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_polar(r: f64, theta: f64) -> Complex {
Complex {
re: r * theta.cos(),
im: r * theta.sin(),
}
}
pub fn real(&self) -> f64 {
self.re
}
pub fn imaginary(&self) -> f64 {
self.im
}
pub fn add(&self, c: &Complex) -... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/effective-java-examples",
"path": "/src/main/rust/chapter04/item15/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn imaginary(&self) -> f64 {
self.im
}
pub fn add(&self, c: &Complex) -> Complex {
Complex {
re: self.re + c.re,
im: self.im + c.im
}
}
}<|fim_prefix|>// repo: Byron/effective-java-examples path: /src/main/rust/chapter04/item15/src/lib.... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/effective-java-examples",
"path": "/src/main/rust/chapter04/item15/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/effective-java-examples path: /src/main/rust/chapter04/item15/src/lib.rs
pub const ZERO: Complex = Complex {re: 0.0, im: 0.0};
pub const ONE: Complex = Complex {re: 1.0, im: 0.0};
pub const I: Complex = Complex {re: 0.0, im: 1.0};
<|fim_suffix|> pub fn real(&self) -> f64 {
sel... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/effective-java-examples",
"path": "/src/main/rust/chapter04/item15/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pythonhacker/project-euler-rust path: /common.rs
use std::fs::File;
use std::path::Path;
use std::io::{self, BufRead};
use std::collections::HashMap;
// Common functions
#[allow(dead_code)]
pub fn is_palindrome(number: u64) -> bool {
let mut n = number;
let mut rev = 0;
le... | code_fim | hard | {
"lang": "rust",
"repo": "pythonhacker/project-euler-rust",
"path": "/common.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
pub fn vector_to_digit_u32(num_vec: Vec<u32>) -> u32 {
let mut num: u32 = 0;
let mut i: u32 = 0;
for n in num_vec.iter().rev() {
num += 10u32.pow(i)*(n);
i += 1;
}
return num;
}
// Is n a prime ?
#[allow(dead_code)]
pub fn is_prime(n... | code_fim | hard | {
"lang": "rust",
"repo": "pythonhacker/project-euler-rust",
"path": "/common.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if x>y {
num = x;
den = y;
} else {
num = y;
den = x;
}
n_gcd = gcd(den, num);
n_lcm = x*y/n_gcd;
return n_lcm;
}
#[allow(dead_code)]
pub fn find_lcm(numbers: &Vec<u64>) -> u64 {
let x:u64 = numbers[0];
let y:u64 = numbers[1];
... | code_fim | hard | {
"lang": "rust",
"repo": "pythonhacker/project-euler-rust",
"path": "/common.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erglabs/common-tools-rs path: /crates/tracing/src/kafka.rs
use std::collections::HashMap;
use opentelemetry::{
global,
propagation::{Extractor, Injector},
};
use rdkafka::{
message::{BorrowedHeaders, BorrowedMessage, Headers, OwnedHeaders},
Message,
};
use tracing_opentelemetry:... | code_fim | hard | {
"lang": "rust",
"repo": "erglabs/common-tools-rs",
"path": "/crates/tracing/src/kafka.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl KafkaProducerHeaders {
fn new(headers: OwnedHeaders) -> Self {
Self { headers }
}
}
impl Injector for KafkaProducerHeaders {
fn set(&mut self, key: &str, value: String) {
let headers = std::mem::take(&mut self.headers);
self.headers = headers.add(key, &value);
... | code_fim | hard | {
"lang": "rust",
"repo": "erglabs/common-tools-rs",
"path": "/crates/tracing/src/kafka.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: typewriter221/playbot_ng path: /playground/src/version.rs
use crate::Channel;
use reqwest::{Client, Error};
use reqwest::r#async as async_reqwest;
use std::future::Future;
use futures::compat::Future01CompatExt;
<|fim_suffix|>#[derive(Deserialize)]
pub struct Version {
pub date: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "typewriter221/playbot_ng",
"path": "/playground/src/version.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(resp)
}
}
#[derive(Deserialize)]
pub struct Version {
pub date: String,
pub hash: String,
pub version: String,
}<|fim_prefix|>// repo: typewriter221/playbot_ng path: /playground/src/version.rs
use crate::Channel;
use reqwest::{Client, Error};
use reqwest::r#async as async_reqw... | code_fim | hard | {
"lang": "rust",
"repo": "typewriter221/playbot_ng",
"path": "/playground/src/version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
pub struct Version {
pub date: String,
pub hash: String,
pub version: String,
}<|fim_prefix|>// repo: typewriter221/playbot_ng path: /playground/src/version.rs
use crate::Channel;
use reqwest::{Client, Error};
use reqwest::r#async as async_reqwest;
use std::future::Futu... | code_fim | hard | {
"lang": "rust",
"repo": "typewriter221/playbot_ng",
"path": "/playground/src/version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
// Ensure that our Rng is similar to the one implemented in Haskell
fn test_random() {
let seed = 12345;
let expected_results = vec![7193,2932,10386,5575,100,15976,430,9740,9449,1636,11030,9848,13965,16051,14483,6708,5184,15931,7014,461,11371,5856,2136,9139,1684,15900,10236,13297,1364,6876... | code_fim | medium | {
"lang": "rust",
"repo": "aochagavia/FastAnts",
"path": "/ant_lib/src/util/rng.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aochagavia/FastAnts path: /ant_lib/src/util/rng.rs
use std::mem;
use std::num::Wrapping;
/// A random number generator
///
/// We could use a Rust library, but we want to be able to replicate the same
/// simulations as the Haskell simulator
pub struct Rng {
stream: Box<Iterator<Item=usize>... | code_fim | hard | {
"lang": "rust",
"repo": "aochagavia/FastAnts",
"path": "/ant_lib/src/util/rng.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whostolemyhat/learning-projects path: /22-matrix/matrix/matrix/src/lib.rs
extern crate rand;
use std::fmt::{ Display, Result, Formatter };
use std::ops::{ Add, Sub, Mul };
use rand::Rng;
#[derive(Debug, Clone)]
pub struct Matrix<T> {
rows: i32,
cols: i32,
matrix: Vec<Vec<T>>
}
impl<T> M... | code_fim | hard | {
"lang": "rust",
"repo": "whostolemyhat/learning-projects",
"path": "/22-matrix/matrix/matrix/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut new_matrix: Matrix<T> = Matrix::new(self.rows, self.cols, Default::default());
for i in 0..self.rows {
let row = i as usize;
for j in 0..self.cols {
let col = j as usize;
new_matrix.matrix[row][col] = self.matrix[row][col] - other.matrix[row][col];
}
... | code_fim | hard | {
"lang": "rust",
"repo": "whostolemyhat/learning-projects",
"path": "/22-matrix/matrix/matrix/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_matrix.matrix[col][row] = self.matrix[row][col];
}
}
new_matrix
}
}
// Make sure generic type T implements Add (so you can add them together)
// Copy so we can copy self.rows/self.cols to new matrix
// and Default, so we can use that to fill the matrix
// <Output=T> ensures t... | code_fim | hard | {
"lang": "rust",
"repo": "whostolemyhat/learning-projects",
"path": "/22-matrix/matrix/matrix/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scturtle/AdventOfCode2020 path: /src/day24.rs
use itertools::Itertools;
use std::collections::{BTreeMap, BTreeSet};
#[rustfmt::skip]
#[derive(PartialEq, Debug, Clone, Copy)]
enum D { E, SE, SW, W, NW, NE }
fn to_dirs(s: &str) -> Vec<D> {
let mut ds = vec![];
let bs = s.bytes().collect_... | code_fim | hard | {
"lang": "rust",
"repo": "scturtle/AdventOfCode2020",
"path": "/src/day24.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cnt = BTreeMap::<_, usize>::new();
for (x, y) in &blacks {
for (xx, yy) in &[(1, 1), (-1, -1), (0, 1), (1, 0), (0, -1), (-1, 0)] {
*cnt.entry((x + xx, y + yy)).or_default() += 1;
}
}
let mut new_blacks = BTreeSet::new();
for (p, c) in &cnt {
... | code_fim | hard | {
"lang": "rust",
"repo": "scturtle/AdventOfCode2020",
"path": "/src/day24.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run() {
let txt = crate::common::get_input(24).unwrap();
let tiles = txt.trim().lines().map(to_dirs).collect_vec();
let mut blacks = BTreeSet::new();
for t in &tiles {
let mut p = (0, 0);
for &d in t {
p = mv(p, d);
}
if !blacks.insert(p) ... | code_fim | hard | {
"lang": "rust",
"repo": "scturtle/AdventOfCode2020",
"path": "/src/day24.rs",
"mode": "spm",
"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.