text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: duzhanyuan/ossuary path: /src/handshake.rs
Each side of the connection must
/// call send_handshake() continuously, and any data that is written to the
/// data buffer must be sent to the remote host. This should be done until
/// [`OssuaryConnection::handshake_done()`] returns tru... | code_fim | hard | {
"lang": "rust",
"repo": "duzhanyuan/ossuary",
"path": "/src/handshake.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lnicola/rust-analyzer path: /crates/ide_completion/src/completions/record.rs
//! Complete fields in record literals and patterns.
use ide_db::SymbolKind;
use syntax::{ast::Expr, T};
use crate::{
patterns::ImmediateLocation, CompletionContext, CompletionItem, CompletionItemKind, Completions,... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/rust-analyzer",
"path": "/crates/ide_completion/src/completions/record.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn create_foo(foo_desc: &FooDesc) -> () { () }
fn baz() {
let foo = create_foo(&FooDesc { bar: ${1:()} }$0);
}
"#,
)
}
#[test]
fn literal_struct_completion_from_sub_modules() {
check_edit(
"Struct {…}",
r#"
mod submod {
pub struct S... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/rust-analyzer",
"path": "/crates/ide_completion/src/completions/record.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::fs::create_dir_all(benchmark_dir).unwrap();
let flamegraph_path = benchmark_dir.join("flamegraph.svg");
let flamegraph_file = File::create(&flamegraph_path)
.expect("File system error while creating flamegraph.svg");
if let Some(profiler) = self.active_prof... | code_fim | medium | {
"lang": "rust",
"repo": "nick-zrymiak/connector-agent-1",
"path": "/connector-agent/benches/profiler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nick-zrymiak/connector-agent-1 path: /connector-agent/benches/profiler.rs
use criterion::profiler::Profiler;
use pprof::ProfilerGuard;
use std::{fs::File, path::Path};
pub struct FlamegraphProfiler<'a> {
frequency: i32,
active_profiler: Option<ProfilerGuard<'a>>,
}
impl<'a> FlamegraphP... | code_fim | medium | {
"lang": "rust",
"repo": "nick-zrymiak/connector-agent-1",
"path": "/connector-agent/benches/profiler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.low_tile_byte = self.read(address);
}
pub fn fetch_high_tile_byte(&mut self) {
let table_base = if self.flag_background_table { 0x1000 } else { 0 };
let fine_y = (self.v >> 12) & 7;
let tile = ((self.nametable_byte as u16) << 4) as u16;
let address = ... | code_fim | hard | {
"lang": "rust",
"repo": "ZacJoffe/znes",
"path": "/src/ppu/render.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn increment_coarse_x(&mut self) {
// https://wiki.nesdev.com/w/index.php/PPU_scrolling#Coarse_X_increment
let coarse_x = self.v & 0x001f;
// handle wrap around if 5 bit course x is at its maximum value
if coarse_x == 0x1f {
self.v &= 0xffe0;
... | code_fim | hard | {
"lang": "rust",
"repo": "ZacJoffe/znes",
"path": "/src/ppu/render.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZacJoffe/znes path: /src/ppu/render.rs
use crate::ppu::PPU;
use crate::ppu::Color;
impl PPU {
pub fn evaluate_sprites(&mut self) {
let sprite_size = if self.flag_sprite_size { 16 } else { 8 };
let mut sprite_count = 0;
for i in 0..64 {
let y = self.oam_d... | code_fim | hard | {
"lang": "rust",
"repo": "ZacJoffe/znes",
"path": "/src/ppu/render.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> closed!(simple_pos, "wp:simplePos", "x", "y");
open!(open_position_h, "wp:positionH", "relativeFrom");
open!(open_position_v, "wp:positionV", "relativeFrom");
closed_with_child!(pos_offset, "wp:posOffset");
closed_with_child!(align, "wp:align");
closed!(wrap_none, "wp:wrapNone");
... | code_fim | hard | {
"lang": "rust",
"repo": "bokuweb/docx-rs",
"path": "/docx-core/src/xml_builder/drawing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bokuweb/docx-rs path: /docx-core/src/xml_builder/drawing.rs
use super::XMLBuilder;
use super::XmlEvent;
impl XMLBuilder {
open!(
open_wp_inline,
"wp:inline",
"distT",
"distB",
"distL",
"distR"
);
open!(
open_wp_anchor,
... | code_fim | hard | {
"lang": "rust",
"repo": "bokuweb/docx-rs",
"path": "/docx-core/src/xml_builder/drawing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saturn-xiv/peony path: /src/plugins/nut/models/vote.rs
use chrono::{NaiveDateTime, Utc};
use diesel::{delete, insert_into, prelude::*, update};
use super::super::super::super::{errors::Result, orm::postgresql::Connection};
use super::super::schema::votes;
#[derive(Queryable, Serialize)]
#[serd... | code_fim | hard | {
"lang": "rust",
"repo": "saturn-xiv/peony",
"path": "/src/plugins/nut/models/vote.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Dao for Connection {
fn like(&self, rty: &str, rid: i64, is: bool) -> Result<()> {
let now = Utc::now().naive_utc();
match votes::dsl::votes
.filter(votes::dsl::resource_type.eq(rty))
.filter(votes::dsl::resource_id.eq(rid))
.first::<Item>(self)... | code_fim | hard | {
"lang": "rust",
"repo": "saturn-xiv/peony",
"path": "/src/plugins/nut/models/vote.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn delete(&self, id: i64) -> Result<()> {
delete(votes::dsl::votes.filter(votes::dsl::id.eq(id))).execute(self)?;
Ok(())
}
fn by_resource_type(&self, rty: &str) -> Result<Vec<Item>> {
let items = votes::dsl::votes
.filter(votes::dsl::resource_type.eq(rty))
... | code_fim | hard | {
"lang": "rust",
"repo": "saturn-xiv/peony",
"path": "/src/plugins/nut/models/vote.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hunainarbani/iotq2 path: /class02/stud_struct/src/main.rs
#[derive(Debug)]
struct Student{
name: String,
age: u8,
address: String
}
impl Student {
pub fn create_student(name: String, age: u8, address: String) -> Student {
let newstudent = Student {
name: na... | code_fim | hard | {
"lang": "rust",
"repo": "hunainarbani/iotq2",
"path": "/class02/stud_struct/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let student_01 = Student::create_student(String::from("Hunain Arbani"),
32,String::from("Bahria Auditorium"));
println!("{}",student_01.view_student());
}<|fim_prefix|>// repo: hunainarbani/iotq2 path: /class02/stud_struct/src/main.rs
#[der... | code_fim | hard | {
"lang": "rust",
"repo": "hunainarbani/iotq2",
"path": "/class02/stud_struct/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: searedcircuit/rustdemo path: /src/data/request/menu/create_menu_request.rs
use serde::{Deserialize,Serialize};
#[derive(Clone,PartialEq,Serialize,Deserialize)]
pub struct CreateMenuRequest{
pub store_id: uuid::Uuid,
pub name: Option<String>,
pub desc: Option<String>,
pub size: V... | code_fim | medium | {
"lang": "rust",
"repo": "searedcircuit/rustdemo",
"path": "/src/data/request/menu/create_menu_request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> CreateMenuRequest {
store_id: uuid::Uuid::default(),
name: None,
desc: None,
size: Vec::new(),
temp: Vec::new(),
cost: None
}
}
}<|fim_prefix|>// repo: searedcircuit/rustdemo path: /src/data/request/menu/create_m... | code_fim | medium | {
"lang": "rust",
"repo": "searedcircuit/rustdemo",
"path": "/src/data/request/menu/create_menu_request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/viska path: /lib/sip_server/src/core/impls/req_processor/registrar.rs
use crate::{Error, SipManager, ReqProcessor};
use common::{
async_trait::async_trait,
rsip::{self, prelude::*},
};
use models::transport::{RequestMsg, ResponseMsg};
use std::{
any::Any,
sync::{Arc, Weak... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/viska",
"path": "/lib/sip_server/src/core/impls/req_processor/registrar.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn has_correct_request_uri(request_uri: &rsip::Uri) -> Result<(), Error> {
if common::CONFIG.contains_addr(&request_uri.host_with_port) {
Ok(())
} else {
Err(Error::from("invalid request uri"))
}
}
fn has_correct_to_request_uri(to_header: &rsip::headers::To) -> Result<(), Erro... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/viska",
"path": "/lib/sip_server/src/core/impls/req_processor/registrar.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zheland/rust-webrtc-p2p-example path: /browser-webrtc/src/lib.rs
#![warn(
clippy::all,
rust_2018_idioms,
missing_copy_implementations,
missing_debug_implementations,
single_use_lifetimes,
trivial_casts,
unused_import_braces,
unused_qualifications,
unused_resul... | code_fim | hard | {
"lang": "rust",
"repo": "zheland/rust-webrtc-p2p-example",
"path": "/browser-webrtc/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use boxfn::{BoxAsyncFn2, BoxAsyncFn2Wrapper};
pub use closure::{closure_0, closure_1};
pub use data_receiver::{DataReceiver, DataReceiverBuilder, DataReceiverError, DataReceiverEvent};
pub use data_sender::{DataSender, DataSenderError, DataSenderEvent, DataSenderSendError};
pub use local_media::LocalM... | code_fim | hard | {
"lang": "rust",
"repo": "zheland/rust-webrtc-p2p-example",
"path": "/browser-webrtc/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/rust-protobuf-sgx path: /protobuf-test/src/common/v2/test_singular_field_option.rs
use super::test_singular_field_option_pb::*;
use protobuf::SingularPtrField;
#[test]
fn test_option_box() {
let w = WithOptionBox::new();
let _inner: &Option<Box<Inner>> = &w.inner;
}
#[te... | code_fim | easy | {
"lang": "rust",
"repo": "mesalock-linux/rust-protobuf-sgx",
"path": "/protobuf-test/src/common/v2/test_singular_field_option.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let w = WithSingularField::new();
let _inner: &SingularPtrField<Inner> = &w.inner;
}<|fim_prefix|>// repo: mesalock-linux/rust-protobuf-sgx path: /protobuf-test/src/common/v2/test_singular_field_option.rs
use super::test_singular_field_option_pb::*;
use protobuf::SingularPtrField;
#[test]
fn tes... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/rust-protobuf-sgx",
"path": "/protobuf-test/src/common/v2/test_singular_field_option.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TLmaK0/rustneat path: /src/ctrnn.rs
use rulinalg::matrix::{BaseMatrix, BaseMatrixMut, Matrix};
#[cfg(feature = "ctrnn_telemetry")]
use rusty_dashed;
#[cfg(feature = "ctrnn_telemetry")]
use serde_json;
#[allow(missing_docs)]
#[derive(Debug)]
pub struct CtrnnNeuralNetwork<'a> {
pub y: &'a [... | code_fim | hard | {
"lang": "rust",
"repo": "TLmaK0/rustneat",
"path": "/src/ctrnn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Matrix::new(vector.len(), 1, vector)
}
fn vector_to_matrix(vector: &[f64]) -> Matrix<f64> {
let width = (vector.len() as f64).sqrt() as usize;
Matrix::new(width, width, vector)
}
#[cfg(feature = "ctrnn_telemetry")]
fn telemetry(y: &Matrix<f64>) {
let y... | code_fim | hard | {
"lang": "rust",
"repo": "TLmaK0/rustneat",
"path": "/src/ctrnn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = include_str!("relay_test_operation/fixtures/prod_query.invalid.graphql");
let expected = include_str!("relay_test_operation/fixtures/prod_query.invalid.expected");
test_fixture(transform_fixture, "prod_query.invalid.graphql", "relay_test_operation/fixtures/prod_query.invalid.expect... | code_fim | medium | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/tests/relay_test_operation_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/relay path: /compiler/crates/relay-transforms/tests/relay_test_operation_test.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated Sig... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/relay",
"path": "/compiler/crates/relay-transforms/tests/relay_test_operation_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> packer.pack(self.as_bytes());
}
}
impl Pack for &BigInt {
fn pack(self, packer: &mut Packer) {
if self.is_zero() {
packer.pack(&[] as &[u8]);
} else {
packer.pack(&self.to_signed_bytes_be() as &[_]);
}
}
}
#[cfg(test)]
mod tests;<|fim_p... | code_fim | hard | {
"lang": "rust",
"repo": "Hakuyume/ssh-agent-notify",
"path": "/rfc4251/src/pack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hakuyume/ssh-agent-notify path: /rfc4251/src/pack.rs
use num_bigint::BigInt;
use num_traits::Zero;
#[derive(Default)]
pub struct Packer(Vec<u8>);
impl Packer {
pub fn inner(self) -> Vec<u8> {
self.0
}
pub fn pack<T>(&mut self, value: T)
where
T: Pack,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "Hakuyume/ssh-agent-notify",
"path": "/rfc4251/src/pack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> packer.pack(self.len() as u32);
packer.write_bytes(self);
}
}
impl Pack for &str {
fn pack(self, packer: &mut Packer) {
packer.pack(self.as_bytes());
}
}
impl Pack for &BigInt {
fn pack(self, packer: &mut Packer) {
if self.is_zero() {
packer.pa... | code_fim | hard | {
"lang": "rust",
"repo": "Hakuyume/ssh-agent-notify",
"path": "/rfc4251/src/pack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thea603/wu path: /src/db/test.rs
pub use bson::Bson;
pub use mongodb::{Client, ThreadedClient};
pub use mongodb::db::ThreadedDatabase;
pub fn testone() -> String {
let client = Client::connect("localhost", 27017)
.expect("Failed to initialize standalone client.");
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "thea603/wu",
"path": "/src/db/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Find the document and receive a cursor
let mut cursor = coll.find(Some(doc.clone()), None)
.ok().expect("Failed to execute find.");
let item = cursor.next();
// cursor.next() returns an Option<Result<Document>>
let mut ptitle = "".to_string();
match item {
Some... | code_fim | hard | {
"lang": "rust",
"repo": "thea603/wu",
"path": "/src/db/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Picahoo/ciruela path: /src/daemon/metadata/first_scan.rs
use std::path::{PathBuf, Path};
use {VPath};
use metadata::dir::Dir;
use metadata::{Meta, Error};
<|fim_suffix|>pub fn scan<F>(meta: &Meta, mut add_dir: F)
-> Result<(), Error>
where F: FnMut(VPath),
{
// TODO(tailhook) thr... | code_fim | hard | {
"lang": "rust",
"repo": "Picahoo/ciruela",
"path": "/src/daemon/metadata/first_scan.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn scan<F>(meta: &Meta, mut add_dir: F)
-> Result<(), Error>
where F: FnMut(VPath),
{
// TODO(tailhook) throttle maybe?
let root = meta.signatures()?;
for (virtual_name, ref cfg) in &meta.0.config.dirs {
if let Some(dir) = root.dir_if_exists(virtual_name)? {
let... | code_fim | hard | {
"lang": "rust",
"repo": "Picahoo/ciruela",
"path": "/src/daemon/metadata/first_scan.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"Part 1 answer {:?}",
run_program_with_tweak(&positions, 12, 2).positions[0]
);
{
let mut found = false;
for a in 0..99 {
for b in 0..99 {
if run_program_with_tweak(&positions, a, b).positions[0] == 19690720 {
... | code_fim | medium | {
"lang": "rust",
"repo": "kenrick95/adventofcode2019",
"path": "/src/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenrick95/adventofcode2019 path: /src/day02.rs
use super::program::*;
fn run_program_with_tweak(positions: &Vec<i128>, a: i128, b: i128) -> State {
let mut temp = positions.clone();
temp[1] = a;
temp[2] = b;
return run_program(
temp,
0,
0,
... | code_fim | hard | {
"lang": "rust",
"repo": "kenrick95/adventofcode2019",
"path": "/src/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ReflectiveIO/mirror path: /src/slg/textures/band.rs
use std::str::FromStr;
use crate::rays::color::Spectrum;
use crate::rays::Properties;
use crate::slg::bsdf::HitPoint;
use crate::slg::image_map::{ImageMap, ImageMapCache};
use crate::slg::textures::texture::TextureType;
use crate::slg::texture... | code_fim | hard | {
"lang": "rust",
"repo": "ReflectiveIO/mirror",
"path": "/src/slg/textures/band.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct BandTexture {
interpolation_type: InterpolationType,
amount: Box<dyn Texture>,
offsets: Vec<f32>,
values: Vec<Spectrum>,
}
impl BandTexture {
pub fn new(
interpolation_type: InterpolationType,
amount: Box<dyn Texture>,
offsets: Vec<f32>,
val... | code_fim | hard | {
"lang": "rust",
"repo": "ReflectiveIO/mirror",
"path": "/src/slg/textures/band.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bollo35/cryptopals path: /src/bin/p022.rs
extern crate ooga;
use ooga::mtwister::MT19937;
use std::time::{self, SystemTime, UNIX_EPOCH};
use std::thread;
extern crate rand;
use rand::distributions::{Range, Sample};
fn main() {
<|fim_suffix|>fn randu32() -> u32 {
let mut rng = rand::thread_rng... | code_fim | hard | {
"lang": "rust",
"repo": "bollo35/cryptopals",
"path": "/src/bin/p022.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
let mut range = Range::new(40, 1000);
let rand_wait = range.sample(&mut rng);
thread::sleep(time::Duration::from_secs(rand_wait));
let systime = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
let mut rng = MT19937::new((systime & 0x00000000FFFFFFFF... | code_fim | hard | {
"lang": "rust",
"repo": "bollo35/cryptopals",
"path": "/src/bin/p022.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SimonWang9610/rust-js-wasm path: /node/wasm/interfaces/src/utils_64.rs
use ndarray::{Array1, Array2, Axis};
pub fn relu(input: Array2<f64>) -> Array2<f64> {
input.mapv_into(|ele| if ele >= 0. { ele } else { 0. })
}
pub fn softmax(mut input: Array2<f64>) -> Array2<f64> {
input.swap_axes... | code_fim | hard | {
"lang": "rust",
"repo": "SimonWang9610/rust-js-wasm",
"path": "/node/wasm/interfaces/src/utils_64.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let predictions = output.map_axis(Axis(1), |row| {
let mut max = (0, 0.);
for (i, ele) in row.iter().enumerate() {
if *ele > max.1 {
max = (i, *ele);
}
}
max.0 as f64
});
let labels = labels.map_axis(Axis(1), |row| {
... | code_fim | hard | {
"lang": "rust",
"repo": "SimonWang9610/rust-js-wasm",
"path": "/node/wasm/interfaces/src/utils_64.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let labels = labels.map_axis(Axis(1), |row| {
let mut max = (0, 0.);
for (i, ele) in row.iter().enumerate() {
if *ele > max.1 {
max = (i, *ele);
}
}
max.0 as f64
});
predictions
.into_iter()
.zip(labels.in... | code_fim | hard | {
"lang": "rust",
"repo": "SimonWang9610/rust-js-wasm",
"path": "/node/wasm/interfaces/src/utils_64.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ingredients = input
.iter()
.map(|e| {
e.ingredients
.iter()
.map(|e| e.to_owned())
.collect::<HashSet<_>>()
})
.collect::<Vec<_>>();
let mut allergens = input
.iter()
.map(|e| {
... | code_fim | hard | {
"lang": "rust",
"repo": "darshanparajuli/AdventOfCode2020",
"path": "/src/bin/day21.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darshanparajuli/AdventOfCode2020 path: /src/bin/day21.rs
use aoc_2020::*;
use std::collections::*;
#[derive(Debug, Clone)]
struct Food {
ingredients: Vec<String>,
allergens: Vec<String>,
}
fn main() {
let input = read_input_map(|e| {
let size = e.len();
let v = e[0.... | code_fim | hard | {
"lang": "rust",
"repo": "darshanparajuli/AdventOfCode2020",
"path": "/src/bin/day21.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shinglyu/loop path: /src/compiler/definition.rs
use crate::compiler::opcode::OpCode;
#[derive(Clone)]
pub struct Definition {
pub name: String, // pretty printed name instead of a byte representation
pub operand_width: Vec<i32>, // how many bits wide each operand is
}
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "shinglyu/loop",
"path": "/src/compiler/definition.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn lookup(op: u8) -> Option<Definition> {
match op {
0 => Some(get_definition(OpCode::Constant)),
1 => Some(get_definition(OpCode::Add)),
2 => Some(get_definition(OpCode::Pop)),
3 => Some(get_definition(OpCode::Closure)),
4 => Some(get_definition(OpCode::Mod... | code_fim | hard | {
"lang": "rust",
"repo": "shinglyu/loop",
"path": "/src/compiler/definition.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn unsigned_types_are_supported() {
assert!(determine_unsigned("float unsigned"));
assert!(determine_unsigned("UNSIGNED INT"));
assert!(determine_unsigned("unsigned bigint"));
assert!(!determine_unsigned("bigint"));
assert!(!determine_unsigned("FLOAT"));
assert_eq!("float",... | code_fim | hard | {
"lang": "rust",
"repo": "peterschwarz/diesel",
"path": "/diesel_cli/src/infer_schema_internals/mysql.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterschwarz/diesel path: /diesel_cli/src/infer_schema_internals/mysql.rs
use diesel::mysql::Mysql;
use diesel::*;
use heck::ToUpperCamelCase;
use std::error::Error;
use super::data_structures::*;
use super::information_schema::UsesInformationSchema;
use super::table_data::TableName;
mod infor... | code_fim | hard | {
"lang": "rust",
"repo": "peterschwarz/diesel",
"path": "/diesel_cli/src/infer_schema_internals/mysql.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> join.await.unwrap();
tokio::time::resume();
// Ensure that finally maintenance is not required.
assert!(writer.maintenance_request().is_none());
})
}
#[test]
fn add() {
let pod = make_pod();
let assert_pod = pod.clone();... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/kubernetes/state/delayed_delete.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alakahakai/vector path: /src/kubernetes/state/delayed_delete.rs
//! A state wrapper that delays deletes.
use async_trait::async_trait;
use futures::{future::BoxFuture, FutureExt};
use std::{collections::VecDeque, time::Duration};
use tokio::time::{delay_until, Instant};
/// A [`super::Write`] ... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/kubernetes/state/delayed_delete.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/connectivity/wlan/lib/mlme/rust/src/block_ack.rs
on may send an ADDBA request frame to the remote peer in
/// order to await an affirmative ADDBA response frame from that peer.
///
/// See IEEE Std 802.11-2016, 10.24.2.
#[allow(dead_code)] // TODO(2988... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/src/connectivity/wlan/lib/mlme/rust/src/block_ack.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/connectivity/wlan/lib/mlme/rust/src/block_ack.rs
7): Provide a `send_delba_frame` function.
/// BlockAck transmitter.
///
/// Types that implement this trait can transmit a BlockAck frame body. Typically, this involves
/// embedding the frame body within a management ... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/src/connectivity/wlan/lib/mlme/rust/src/block_ack.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn simplify_union<'a>(env: &mut Env<'a>, ty1: Ty<'a>, ty2: Ty<'a>) -> Option<Ty<'a>> {
// TODO(hrust) log
// TODO(hrust) check ty_equal
if typing_subtype::is_sub_type_for_union(env, ty1, ty2) {
Some(ty2)
} else if typing_subtype::is_sub_type_for_union(env, ty2, ty1) {
S... | code_fim | hard | {
"lang": "rust",
"repo": "IceCruelStuff/hhvm",
"path": "/hphp/hack/src/typing/typing_union.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IceCruelStuff/hhvm path: /hphp/hack/src/typing/typing_union.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use crate::typing_subtype;
use crate::Env;
use bu... | code_fim | hard | {
"lang": "rust",
"repo": "IceCruelStuff/hhvm",
"path": "/hphp/hack/src/typing/typing_union.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn make_union<'a>(env: &mut Env<'a>, tys: &'a [Ty<'a>]) -> Ty<'a> {
let bld = env.bld();
// TODO(hrust) treat null and nonnull properly, build nullable type if necessary...
// TODO(hrust) build proper like type if necessary
bld.union(bld.mk_rnone(), tys) // TODO(hrust) proper reason
}
... | code_fim | hard | {
"lang": "rust",
"repo": "IceCruelStuff/hhvm",
"path": "/hphp/hack/src/typing/typing_union.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: overminder/tcp-graceful-shutdown path: /multi-nc/src/main.rs
extern crate multi_nc;
use std::env;
<|fim_suffix|>fn main() {
let port = env::var("PORT")
.unwrap_or("6789".to_owned())
.parse().unwrap();
let expected_len = env::var("BS_LEN")
.unwrap_or("1000".to_ow... | code_fim | medium | {
"lang": "rust",
"repo": "overminder/tcp-graceful-shutdown",
"path": "/multi-nc/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let port = env::var("PORT")
.unwrap_or("6789".to_owned())
.parse().unwrap();
let expected_len = env::var("BS_LEN")
.unwrap_or("1000".to_owned())
.parse().unwrap();
spawn_checkers(port, expected_len);
}<|fim_prefix|>// repo: overminder/tcp-graceful-sh... | code_fim | medium | {
"lang": "rust",
"repo": "overminder/tcp-graceful-shutdown",
"path": "/multi-nc/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_variables)]
fn __action7<
'input,
>(
input: &'input str,
(_, __0, _): (usize, Box<Expr>, usize),
) -> Box<Expr>
{
(__0)
}
#[allow(unused_variables)]
fn __action8<
'input,
>(
input: &'input str,
(_, __0, _): (usize, &'input str, usize),
) -> Opcode
{
Opcode::... | code_fim | hard | {
"lang": "rust",
"repo": "kkragoth-mimuw/instant",
"path": "/src/instant_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kkragoth-mimuw/instant path: /src/instant_parser.rs
x<Stmt>, __lalrpop_util::ParseError<usize, Token<'input>, &'static str>>
{
let mut __tokens = self.builder.matcher(input);
let __r = __state_machine::Parser::drive(
__StateMachine {
... | code_fim | hard | {
"lang": "rust",
"repo": "kkragoth-mimuw/instant",
"path": "/src/instant_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl __MatcherBuilder {
pub fn new() -> __MatcherBuilder {
let __strs: &[&str] = &[
"^([0-9]+)",
"^([A-Za-z][0-9A-Z_a-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ\u{300}-ʹͶ-ͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ\u{483}-ԯԱ-Ֆՙՠ-ֈ\u{591}-\u{5bd}\u{5bf}\u{5c1}-\u{5c2}\u{5c4}-\u{5c5}\u{5c7}א-תׯ-ײ... | code_fim | hard | {
"lang": "rust",
"repo": "kkragoth-mimuw/instant",
"path": "/src/instant_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>a * b * c);
}
b += 1;
c -= 1;
}
}
None
}<|fim_prefix|>// repo: ryym/exercism path: /rust/pythagorean-triplet/src/lib.rs
const SUM: u32 = 1000;
pub fn find() -> Option<u32> {
let a_ceil = (SUM as f64 / 3f64).floor() as u32;
for a in 1..a_ceil {
... | code_fim | medium | {
"lang": "rust",
"repo": "ryym/exercism",
"path": "/rust/pythagorean-triplet/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryym/exercism path: /rust/pythagorean-triplet/src/lib.rs
const SUM: u32 = 1000;
pub fn find() -> Option<u32> {
let a_ceil = (SUM as f64 / 3f64)<|fim_suffix|>a - b;
while c > b {
if a*a + b*b == c*c {
return Some(a * b * c);
}
b += ... | code_fim | medium | {
"lang": "rust",
"repo": "ryym/exercism",
"path": "/rust/pythagorean-triplet/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: influxdata/flux path: /libflux/flux-core/benches/scanner.rs
#[macro_use]
extern crate criterion;
extern crate fluxcore;
use criterion::{black_box, Criterion};
use fluxcore::scanner;
const FLUX: &str = r#"from(bucket: "benchtest")
# Here's a random comment
|> range(start: -10m)
|> m... | code_fim | medium | {
"lang": "rust",
"repo": "influxdata/flux",
"path": "/libflux/flux-core/benches/scanner.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("scanner.scan", |b| {
b.iter(black_box(|| {
let mut s = scanner::Scanner::new(FLUX);
loop {
let token = s.scan();
if token.tok == scanner::TokenType::Eof {
break;
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "influxdata/flux",
"path": "/libflux/flux-core/benches/scanner.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danicampa90/helmod-graphviz path: /src/dot_writer.rs
use crate::productionchain::ProductionChain;
use crate::recipes::{Recipe, RecipeDatabase};
use std::collections::HashSet;
use std::fs::OpenOptions;
use std::io::prelude::*;
struct IngredientNodeDeclarator(HashSet<String>);
impl IngredientNod... | code_fim | hard | {
"lang": "rust",
"repo": "danicampa90/helmod-graphviz",
"path": "/src/dot_writer.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut makefile = OpenOptions::new()
.write(true)
.create(true)
.open("Makefile")
.unwrap();
write!(makefile, "all:");
for i in 0..count {
write!(makefile, " {0}.png", i);
}
writeln!(makefile, "");
writeln!(makefile, ".PHONY: all");
f... | code_fim | hard | {
"lang": "rust",
"repo": "danicampa90/helmod-graphviz",
"path": "/src/dot_writer.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msgpo/pH path: /src/vm/arch/mod.rs
use crate::kvm::{KvmVcpu, Kvm};
pub use crate::vm::arch::x86::X86ArchSetup;
use crate::memory::MemoryManager;
<|fim_suffix|> fn create_memory(&mut self, kvm: &Kvm) -> Result<MemoryManager>;
fn setup_memory(&mut self, cmdline: &KernelCmdLine, pci_irqs: &... | code_fim | hard | {
"lang": "rust",
"repo": "msgpo/pH",
"path": "/src/vm/arch/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn create_setup(config: &VmConfig) -> X86ArchSetup {
X86ArchSetup::create(config)
}
pub trait ArchSetup {
fn open_kvm(&self) -> Result<Kvm>;
fn create_memory(&mut self, kvm: &Kvm) -> Result<MemoryManager>;
fn setup_memory(&mut self, cmdline: &KernelCmdLine, pci_irqs: &[PciIrq]) -> Res... | code_fim | hard | {
"lang": "rust",
"repo": "msgpo/pH",
"path": "/src/vm/arch/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TrustTheRust/rust-actix-realworld-example-app path: /src/app/articles/favorite_article.rs
use super::get_article::CanGetArticle;
use super::res;
use crate::db;
use crate::mdl::{Article, User};
use crate::prelude::*;
register_service!(FavoriteArticle);
pub trait CanFavoriteArticle {
fn favo... | code_fim | hard | {
"lang": "rust",
"repo": "TrustTheRust/rust-actix-realworld-example-app",
"path": "/src/app/articles/favorite_article.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // XXX: This queries the article again.
self.get_article(&article.slug, Some(user))
}
}<|fim_prefix|>// repo: TrustTheRust/rust-actix-realworld-example-app path: /src/app/articles/favorite_article.rs
use super::get_article::CanGetArticle;
use super::res;
use crate::db;
use crate::mdl:... | code_fim | hard | {
"lang": "rust",
"repo": "TrustTheRust/rust-actix-realworld-example-app",
"path": "/src/app/articles/favorite_article.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> i32, j as i32];
}
}
}
vec![-1, -1]
}
}<|fim_prefix|>// repo: kgrech/rust-algorithms path: /001_two_sum/src/brute_force.rs
pub struct Solution {}
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32)<|fim_middle|> -> Vec<i32> {
for i in 0... | code_fim | hard | {
"lang": "rust",
"repo": "kgrech/rust-algorithms",
"path": "/001_two_sum/src/brute_force.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kgrech/rust-algorithms path: /001_two_sum/src/brute_force.rs
pub struct Solution {}
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32)<|fim_suffix|> i32, j as i32];
}
}
}
vec![-1, -1]
}
}<|fim_middle|> -> Vec<i32> {
for i in 0... | code_fim | hard | {
"lang": "rust",
"repo": "kgrech/rust-algorithms",
"path": "/001_two_sum/src/brute_force.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> type_tree;
pub mod types;
pub(crate) use fresh::Fresh;
pub(crate) use type_tree::TypedAst;<|fim_prefix|>// repo: AngelOfSol/weiss-schwarz-dsl path: /rules/src/executor/semantic_analysis/hm.rs
pub mod fresh;
pub mod substitution;
pub mod t<|fim_middle|>ype_environment;
pub mod type_schemes;
pub mod | code_fim | easy | {
"lang": "rust",
"repo": "AngelOfSol/weiss-schwarz-dsl",
"path": "/rules/src/executor/semantic_analysis/hm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AngelOfSol/weiss-schwarz-dsl path: /rules/src/executor/semantic_analysis/hm.rs
pub mod fresh;
pub mod substitution;
pub mod type_environment;
pub mod type_schemes;
pub mod<|fim_suffix|>sh::Fresh;
pub(crate) use type_tree::TypedAst;<|fim_middle|> type_tree;
pub mod types;
pub(crate) use fre | code_fim | easy | {
"lang": "rust",
"repo": "AngelOfSol/weiss-schwarz-dsl",
"path": "/rules/src/executor/semantic_analysis/hm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmrath/fina-server path: /model/src/schema/core.rs
use diesel::table;
table! {
app_user (id) {
id -> Int8,
created_at -> Timestamptz,
updated_at -> Timestamptz,
version -> Int4,
first_name -> Text,
last_name -> Text,
username -> Text,
... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/fina-server",
"path": "/model/src/schema/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
table! {
timezone (id) {
id -> Int4,
name -> Text,
gmt_offset -> Text,
location -> Text,
}
}
table! {
user_password (user_id) {
user_id -> Int8,
created_at -> Timestamptz,
updated_at -> Timestamptz,
hash -> Text,
expiry... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/fina-server",
"path": "/model/src/schema/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>table! {
user_password (user_id) {
user_id -> Int8,
created_at -> Timestamptz,
updated_at -> Timestamptz,
hash -> Text,
expiry_date -> Timestamptz,
}
}
joinable!(message_address -> message (message_id));
joinable!(message_attachment -> message (message_id))... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/fina-server",
"path": "/model/src/schema/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /metrics-server/src/tokio_task.rs
use std::{collections::HashMap, sync::Arc, time::Duration};
use parking_lot::RwLock;
use prometheus_client::{metrics::gauge::Gauge, registry::Registry};
use tokio_metrics::{TaskMetrics, TaskMonitor};
const TOKIO_METRICS_FREQ_SECS:... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/metrics-server/src/tokio_task.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update_tokio_task_metrics(&mut self, task_name: &str, interval: TaskMetrics) {
self.update_metric_value(
format!("{}_{}", task_name, TOKIO_TASK_METRICS_NAME[0]),
interval.instrumented_count,
);
self.update_metric_value(
format!("{}_{}"... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/metrics-server/src/tokio_task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
interval.tick().await;
if let Some(interval) = runtime_intervals.next() {
tokio_task_metrics
.write()
.update_tokio_task_metrics(task_name, interval);
}
}
}
pub fn update_metric_valu... | code_fim | hard | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/metrics-server/src/tokio_task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: strake/linea.rs path: /src/projective.rs
use generic_array::GenericArray as Array;
use typenum::*;
use super::*;
#[inline]
pub fn translate<A: Copy, N>(a: Matrix<A, N>) -> Matrix<A, Add1<N>, Add1<N>>
where A: Zero + One,
N: Add<B1> + ArrayLength<A>,
Add1<N>: ArrayLength<A> + ... | code_fim | hard | {
"lang": "rust",
"repo": "strake/linea.rs",
"path": "/src/projective.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> b: Matrix<A, N, N>) -> bool
where A: Zero + Mul + One,
A::Output: Copy + PartialEq + Zero + AddAssign + One,
N: Add<B1> +
ArrayLength<A> + ArrayLength<GenericArray<A, N>> +
ArrayLength<A::Outpu... | code_fim | medium | {
"lang": "rust",
"repo": "strake/linea.rs",
"path": "/src/projective.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/rustix/src/backend/libc/mm/syscalls.rs
//! libc syscalls supporting `rustix::mm`.
#[cfg(not(target_os = "redox"))]
use super::types::Advice;
#[cfg(any(target_os = "emscripten", target_os = "linux"))]
use super::types::MremapFlags;
use super::types::{MapFlag... | code_fim | hard | {
"lang": "rust",
"repo": "giodamelio/little_boxes",
"path": "/vendor/rustix/src/backend/libc/mm/syscalls.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) unsafe fn mprotect(
ptr: *mut c::c_void,
len: usize,
flags: MprotectFlags,
) -> io::Result<()> {
ret(c::mprotect(ptr, len, bitflags_bits!(flags)))
}
pub(crate) unsafe fn munmap(ptr: *mut c::c_void, len: usize) -> io::Result<()> {
ret(c::munmap(ptr, len))
}
/// # Safety
///... | code_fim | hard | {
"lang": "rust",
"repo": "giodamelio/little_boxes",
"path": "/vendor/rustix/src/backend/libc/mm/syscalls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cassin01/rubyst path: /src/read_code/mod.rs
use std::env;
use std::fs::File;
use std::io::prelude::*;
<|fim_suffix|> file.read_to_string(&mut texts)
.expect("something went wrong reading the file");
texts
}<|fim_middle|>pub fn read_code() -> String {
let args: Vec<String> = ... | code_fim | hard | {
"lang": "rust",
"repo": "Cassin01/rubyst",
"path": "/src/read_code/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> file.read_to_string(&mut texts)
.expect("something went wrong reading the file");
texts
}<|fim_prefix|>// repo: Cassin01/rubyst path: /src/read_code/mod.rs
use std::env;
use std::fs::File;
use std::io::prelude::*;
<|fim_middle|>pub fn read_code() -> String {
let args: Vec<String> = ... | code_fim | hard | {
"lang": "rust",
"repo": "Cassin01/rubyst",
"path": "/src/read_code/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doraneko94/avlsort path: /src/traits.rs
//! Traits for elements of AVL tree.
use num_traits::Zero;
use rand::distributions::{Uniform, Distribution};
use std::cmp::Ordering;
use std::fmt;
use std::ops::Add;
/// Elements of AVL tree.
pub trait TreeElem: PartialEq + PartialOrd + Copy + fmt::Disp... | code_fim | hard | {
"lang": "rust",
"repo": "doraneko94/avlsort",
"path": "/src/traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{}", self.value)
}
}
impl<T: TreeElem> Add for OrdEqElem<T> {
type Output = Self;
fn add(self, other: Self) -> Self::Output {
Self { value: self.value + other.value }
}
}
impl<T: TreeElem> Zero for OrdEqElem<T> {
fn zero() -> Self {
Self { value: T:... | code_fim | hard | {
"lang": "rust",
"repo": "doraneko94/avlsort",
"path": "/src/traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn consume_offset_topic(cluster_id: ClusterId, consumer: StreamConsumer<EmptyConsumerContext>,
cache: &Cache) -> Result<()> {
let mut local_cache = HashMap::new();
let mut last_dump = Instant::now();
debug!("Starting offset consumer loop for {:?}", cluster_id);
fo... | code_fim | hard | {
"lang": "rust",
"repo": "listenbehind/kafka-view",
"path": "/src/offsets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cluster_id_clone = cluster_id.clone();
let cache_alias = cache.alias();
let _ = thread::Builder::new()
.name("offset-consumer".to_owned())
.spawn(move || {
if let Err(e) = consume_offset_topic(cluster_id_clone, consumer, &cache_alias) {
format_er... | code_fim | hard | {
"lang": "rust",
"repo": "listenbehind/kafka-view",
"path": "/src/offsets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: listenbehind/kafka-view path: /src/offsets.rs
use byteorder::{BigEndian, ReadBytesExt};
use futures::Stream;
use rdkafka::{Message, TopicPartitionList, Offset};
use rdkafka::config::{ClientConfig, TopicConfig};
use rdkafka::consumer::stream_consumer::StreamConsumer;
use rdkafka::consumer::{Consu... | code_fim | hard | {
"lang": "rust",
"repo": "listenbehind/kafka-view",
"path": "/src/offsets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RevinderDev/ajour path: /crates/core/src/backup.rs
use crate::error::FilesystemError;
use crate::fs::backup::{Backup, ZipBackup, ZstdBackup};
use crate::repository::CompressionFormat;
use chrono::{Local, NaiveDateTime};
use std::convert::TryFrom;
use std::path::{Path, PathBuf};
/// Creates a .... | code_fim | hard | {
"lang": "rust",
"repo": "RevinderDev/ajour",
"path": "/crates/core/src/backup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn try_from(path: PathBuf) -> Result<Archive, chrono::ParseError> {
let mut file_stem = path.file_stem().unwrap().to_str().unwrap();
// in the case of "file.tar.zst" path.file_stem() will return "file.tar", we still need to
// drop the extension
if let Some(i) = file_s... | code_fim | hard | {
"lang": "rust",
"repo": "RevinderDev/ajour",
"path": "/crates/core/src/backup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ray33ee/LastLinkedList path: /src/main.rs
use std::rc::Rc;
use std::rc::Weak;
use std::cell::RefCell;
use std::time::{Instant};
use std::collections::LinkedList;
type NodeRef<T> = Option<Rc<RefCell<Node<T>>>>;
type NodeWeak<T> = Option<Weak<RefCell<Node<T>>>>;
struct Node<T>
{
_next: Node... | code_fim | hard | {
"lang": "rust",
"repo": "ray33ee/LastLinkedList",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._reference = None;
loop {
match node.take() {
Some(raw_node) => {
let next_node = raw_node.borrow()._next.clone();
match Rc::try_unwrap(raw_node) {
Ok(ref_cell) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "ray33ee/LastLinkedList",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn append(&mut self, data: T) {
let ref_node = Rc::new(RefCell::new(Node::new(None, data)));
match self._tail.take() {
Some(ref old_tail) => {
let strong_tail = old_tail.upgrade().unwrap();
strong_tail.borrow_mut()._next = Some(ref_node.clo... | code_fim | hard | {
"lang": "rust",
"repo": "ray33ee/LastLinkedList",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/usbhsh/fladj_frindex.rs
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::FLADJ_FRINDEX {
#[doc = r"Modifies the contents of the register"]
#[inli... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/usbhsh/fladj_frindex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>3f);
self.w
}
}
#[doc = r"Reader of the field"]
pub type FRINDEX_R = crate::FR<u16, u16>;
#[doc = r"Proxy"]
pub struct _FRINDEXW<'a> {
w: &'a mut W,
}
impl<'a> _FRINDEXW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u16) -> &'a... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/usbhsh/fladj_frindex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn constructor(
name: InternedString,
len: usize,
type_descriptor: StructTypeDescriptor,
) -> SteelVal {
// let out_name = Arc::clone(&name);
let f = move |args: &[SteelVal]| -> Result<SteelVal> {
if args.len() != len {
let error... | code_fim | hard | {
"lang": "rust",
"repo": "mattwparas/steel",
"path": "/crates/steel-core/src/values/structs.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.