text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn env(&self) -> Env {
self.env
}
fn from_sys_checked(env: Env, value: sys::napi_value) -> Result<String> {
if Any::with_value(env, value).value_type()? != ValueType::String {
let message = String::from_str(env, "String expected")?;
return Err(Error::ty... | code_fim | hard | {
"lang": "rust",
"repo": "aqrln/jsfest2019-napi-rust",
"path": "/examples-rust/napi/src/value/string.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aqrln/jsfest2019-napi-rust path: /examples-rust/napi/src/value/string.rs
use std::ptr;
use crate::env::Env;
use crate::result::{Error, Result};
use crate::sys;
use super::{Any, AsObject, Value, ValueInternal, ValueType};
#[derive(Clone, Copy, Debug)]
pub struct String {
value: sys::napi_v... | code_fim | hard | {
"lang": "rust",
"repo": "aqrln/jsfest2019-napi-rust",
"path": "/examples-rust/napi/src/value/string.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
pub struct VertexP {
pub position : Coords3D,
}
impl VertexP {
pub fn from_coords(position: Coords3D) -> VertexP {
VertexP {
position
}
}
// -- Upgraders -- //
pub fn add_color(self, colour: Colour) -> Verte... | code_fim | hard | {
"lang": "rust",
"repo": "E314c/rusty-craft",
"path": "/src/obj/vertex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Position info:
gl::EnableVertexAttribArray(0); // this is "layout (location = 0)" in vertex shader
gl::VertexAttribPointer(
0, // index of the generic vertex attribute ("layout (location = 0)")
3, // the number of components per generi... | code_fim | hard | {
"lang": "rust",
"repo": "E314c/rusty-craft",
"path": "/src/obj/vertex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: E314c/rusty-craft path: /src/obj/vertex.rs
// TODO: Move to nalgebra matrix implementations
#[derive(Debug)]
pub enum Error {
InvalidVectorLength,
}
#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
pub struct Coords3D {
pub x : f32,
pub y : f32,
pub z : f32,
}
impl Coords3D {
... | code_fim | hard | {
"lang": "rust",
"repo": "E314c/rusty-craft",
"path": "/src/obj/vertex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let query_args = format_ident!("query_args");
let output = if data
.describe
.columns()
.iter()
.all(|it| it.type_info().is_void())
{
let db_path = DB::db_path();
let sql = &input.sql;
quote! {
::sqlx::query_with::<#db_path,... | code_fim | hard | {
"lang": "rust",
"repo": "launchbadge/sqlx",
"path": "/sqlx-macros-core/src/query/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<DB: Database> DescribeExt for Describe<DB> where
Describe<DB>: serde::Serialize + serde::de::DeserializeOwned
{
}
fn expand_with_data<DB: DatabaseExt>(
input: QueryMacroInput,
data: QueryData<DB>,
offline: bool,
) -> crate::Result<TokenStream>
where
Describe<DB>: DescribeExt,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "launchbadge/sqlx",
"path": "/sqlx-macros-core/src/query/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: launchbadge/sqlx path: /sqlx-macros-core/src/query/mod.rs
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::{fs, io};
use once_cell::sync::Lazy;
use proc_macro2::TokenStream;
use syn::Type;
pub use input::QueryMacroInput;
use quote::{format_ident, quote};
use sqlx_core::database::D... | code_fim | hard | {
"lang": "rust",
"repo": "launchbadge/sqlx",
"path": "/sqlx-macros-core/src/query/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raskr/rust-autograd path: /src/optimizers/adagrad.rs
//! Adagrad optimizer
use crate::optimizers::Optimizer;
use crate::tensor::Tensor;
use crate::tensor_ops::gradient_descent_ops::adagrad;
use crate::variable::VariableID;
use crate::{Context, Float, VariableEnvironment};
/// Adagrad optimizer... | code_fim | hard | {
"lang": "rust",
"repo": "raskr/rust-autograd",
"path": "/src/optimizers/adagrad.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, VisitEntities, VisitEntitiesMut)]
pub struct Select {
pub record: specs::Entity,
pub field: String,
}
#[derive(Debug, VisitEntities, VisitEntitiesMut)]
pub struct Apply {
pub function: specs::Entity,
pub parameters: Vec<specs::Entity>,
}
#[derive(Debug, VisitEntities, Vis... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/tin",
"path": "/src/ir/component/element.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/tin path: /src/ir/component/element.rs
use std::collections;
use std::fmt;
use specs;
use specs::Component;
use specs::VecStorage;
#[derive(Component, Debug, VisitEntities, VisitEntitiesMut)]
#[storage(VecStorage)]
pub enum Element {
Number(Number),
String(String),
Symbol(... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/tin",
"path": "/src/ir/component/element.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rmazza/rust-tutorial path: /src/main.rs
fn main() {
variables_and_mutability();
tuple_type();
array_type();
function_example_one(3,4);
control_flow();
ownership();
}
fn ownership(){
let s = "hello";
// String. This type is allocated on the heap and as such is ab... | code_fim | hard | {
"lang": "rust",
"repo": "rmazza/rust-tutorial",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x + 1 // expression
// x + 1; with the semicolon will get error because it is now a statement
}
fn variables_and_mutability() {
// constant
const MAX_POINTS: u32 = 100;
println!("x value: {}", MAX_POINTS);
// mutable, variables are immutable by default
... | code_fim | hard | {
"lang": "rust",
"repo": "rmazza/rust-tutorial",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb-contract-guidelines path: /rust/contracts/nft-validator/src/validator.rs
// Import from `core` instead of from `std` since we are in no-std mode
use core::result::Result;
// Import heap related library from `alloc`
// https://doc.rust-lang.org/alloc/index.html
use alloc::{coll... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb-contract-guidelines",
"path": "/rust/contracts/nft-validator/src/validator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Now we can loop through each output NFT and validate them:
// 1. If an NFT is found in consumed_nfts, this will be a transfer operation,
// no further work is needed.
// 2. If an NFT is not found in consumed_nfts, first, we need to ensure the
// script is in governance_mode, since N... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb-contract-guidelines",
"path": "/rust/contracts/nft-validator/src/validator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use SysError::*;
match err {
IndexOutOfBound => Self::IndexOutOfBound,
ItemMissing => Self::ItemMissing,
LengthNotEnough(_) => Self::LengthNotEnough,
Encoding => Self::Encoding,
Unknown(err_code) => panic!("unexpected sys error {}... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb-contract-guidelines",
"path": "/rust/contracts/nft-validator/src/validator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vadixidav/orbtk path: /src/lib.rs
#![crate_name = "orbtk"]
#![crate_type = "lib"]
// #![deny(warnings)]
#![feature(const_fn)]
pub use dces::prelude::*;
<|fim_suffix|>pub mod application;
pub mod backend;
pub mod enums;
pub mod event;
pub mod layout_object;
pub mod render_object;
pub mod proper... | code_fim | hard | {
"lang": "rust",
"repo": "vadixidav/orbtk",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern crate cssparser;
#[macro_use]
extern crate lazy_static;
pub use crate::application::*;
pub use crate::backend::*;
pub use crate::enums::{*, NotFound};
pub use crate::event::*;
pub use crate::layout_object::*;
pub use crate::render_object::*;
pub use crate::properties::*;
pub use crate::systems::*;... | code_fim | medium | {
"lang": "rust",
"repo": "vadixidav/orbtk",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod application;
pub mod backend;
pub mod enums;
pub mod event;
pub mod layout_object;
pub mod render_object;
pub mod properties;
pub mod systems;
pub mod theme;
pub mod widget;
extern crate orbclient;
extern crate orbfont;
extern crate orbimage;
pub use orbclient::color::Color;<|fim_prefix|>// repo:... | code_fim | hard | {
"lang": "rust",
"repo": "vadixidav/orbtk",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /garnet/bin/setui/src/display/display_fidl_handler.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::switchboard::base::*,
crate::sw... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/garnet/bin/setui/src/display/display_fidl_handler.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fasync::spawn(async move {
while let Ok(Some(req)) = stream.try_next().await {
// Support future expansion of FIDL
#[allow(unreachable_patterns)]
match req {
DisplayRequest::Set { settings, responder } => {
if let Some(req... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/garnet/bin/setui/src/display/display_fidl_handler.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((Radix::from(radix.unwrap()).unwrap(), exactness.unwrap()))
}
fn get_complex(&mut self, radix: Radix, exactness: bool) -> Result<Complex> {
// case 11 12
match (self.peek(), self.peek(), self.peek()) {
(Some('+'), Some('i'), last) |
(Some('-'), S... | code_fim | hard | {
"lang": "rust",
"repo": "shadw3002/risp",
"path": "/src/lexer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r1 = self.get_real(radix, exactness)?;
let (ch, location) = self.peek_with_location();
Ok(match ch {
Some(ch) if is_delimiter(ch) => {
self.reset();
Complex::Real(r1)
},
None => {
self.reset();... | code_fim | hard | {
"lang": "rust",
"repo": "shadw3002/risp",
"path": "/src/lexer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadw3002/risp path: /src/lexer.rs
(Some('-'), Some('n')) => {
self.reset();
self.get_infnan()
},
(Some('+'), _) => {
self.reset();
self.advance();
self.get_unreal(radix, exactness)
... | code_fim | hard | {
"lang": "rust",
"repo": "shadw3002/risp",
"path": "/src/lexer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iotaledger/bee path: /bee-network/bee-gossip/src/tests/common/shutdown.rs
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use std::future::Future;
<|fim_suffix|>pub fn shutdown(secs: u64) -> impl Future + Send + Unpin {
Box::new(Box::pin(time::sleep(Duration::fr... | code_fim | easy | {
"lang": "rust",
"repo": "iotaledger/bee",
"path": "/bee-network/bee-gossip/src/tests/common/shutdown.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn shutdown(secs: u64) -> impl Future + Send + Unpin {
Box::new(Box::pin(time::sleep(Duration::from_secs(secs))))
}<|fim_prefix|>// repo: iotaledger/bee path: /bee-network/bee-gossip/src/tests/common/shutdown.rs
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use std:... | code_fim | easy | {
"lang": "rust",
"repo": "iotaledger/bee",
"path": "/bee-network/bee-gossip/src/tests/common/shutdown.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Arrays have type [T; N] where T is the type of the elements of
// the array and N is a compile-time constant, for the length of
// the array.
// There's shorthand for initializing each element of an array to
// the same value:
let same_value: [i32; 20] = [0; 20];
// You can g... | code_fim | medium | {
"lang": "rust",
"repo": "nachoba/rust",
"path": "/essential-rust/010-arrays.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nachoba/rust path: /essential-rust/010-arrays.rs
/* Arrays in Rust
* --------------
* Rust has list types to represent a sequence of things. The most
* basic is the "array", a fixed-size list of elements of the same
* type. By default, arrays are immutable
*/
fn main() {
let a... | code_fim | medium | {
"lang": "rust",
"repo": "nachoba/rust",
"path": "/essential-rust/010-arrays.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // You can get the number of elements in an array with the
// .len() method
println!("a has {} elements", a.len());
// You can access a particular element of an array with a subscript
// notation:
let names: [&str; 3] = ["Batman", "Superman", "Thor"];
println!("The second superhero i... | code_fim | medium | {
"lang": "rust",
"repo": "nachoba/rust",
"path": "/essential-rust/010-arrays.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frezc/leetcode-solutions path: /src/n0051_n_queens.rs
/**
* [51] N-Queens
*
* The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
*
* <img alt="" src="https://assets.leetcode.com/uploads/2018/10/12/8-queens.png" style... | code_fim | hard | {
"lang": "rust",
"repo": "Frezc/leetcode-solutions",
"path": "/src/n0051_n_queens.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use crate::*;
#[test]
fn test_51() {
assert_vec2_eq(&Solution::solve_n_queens(4), &vec![
strvec![".Q..", // Solution 1
"...Q",
"Q...",
"..Q."],
strvec!["..Q.", // So... | code_fim | hard | {
"lang": "rust",
"repo": "Frezc/leetcode-solutions",
"path": "/src/n0051_n_queens.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: S-H-GAMELINKS/rust.sample path: /if.rs
fn main() {
let flag: bool = true;
<|fim_suffix|> println!("Flag is false");
}
}<|fim_middle|>
if flag {
println!("Flag is {:?}", flag);
} else {
| code_fim | medium | {
"lang": "rust",
"repo": "S-H-GAMELINKS/rust.sample",
"path": "/if.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Flag is false");
}
}<|fim_prefix|>// repo: S-H-GAMELINKS/rust.sample path: /if.rs
fn main() {
let flag: bool = true;
<|fim_middle|>
if flag {
println!("Flag is {:?}", flag);
} else {
| code_fim | medium | {
"lang": "rust",
"repo": "S-H-GAMELINKS/rust.sample",
"path": "/if.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: S-H-GAMELINKS/rust.sample path: /if.rs
fn main() {
let flag: bool = true;
<|fim_suffix|>g is {:?}", flag);
} else {
println!("Flag is false");
}
}<|fim_middle|>
if flag {
println!("Fla | code_fim | easy | {
"lang": "rust",
"repo": "S-H-GAMELINKS/rust.sample",
"path": "/if.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tari-project/tari path: /base_layer/mmr/src/merkle_proof.rs
// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must ret... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/base_layer/mmr/src/merkle_proof.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
D: Digest + DomainDigest,
B: ArrayLike<Value = Hash>,
{
// check we actually have a hash in the MMR at this pos
mmr.get_node_hash(pos)?.ok_or(MerkleProofError::HashNotFound(pos))?;
let mmr_size = mmr.len()?;
let family_branch = family_branch(po... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/base_layer/mmr/src/merkle_proof.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pre-computed builders
lazy_static::lazy_static! {
pub static ref BASE: Builder = {
let mut hm: HashMap<NonNullString, SyscallRule> = HashMap::with_capacity(SYSCALLS_BASE.len());
for name in SYSCALLS_BASE {
// Parameter condition: index=0, value={0x00, 0x08, 0x20000, 0x20... | code_fim | hard | {
"lang": "rust",
"repo": "mmoessmer/northstar",
"path": "/northstar/src/seccomp/profiles/default.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmoessmer/northstar path: /northstar/src/seccomp/profiles/default.rs
use crate::{
common::non_null_string::NonNullString,
seccomp::{
bpf::{builder_from_rules, Builder},
SyscallArgRule, SyscallRule,
},
};
use std::{collections::HashMap, convert::TryInto};
// Filter li... | code_fim | hard | {
"lang": "rust",
"repo": "mmoessmer/northstar",
"path": "/northstar/src/seccomp/profiles/default.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Result::Err(BuiltinEmitError::CompilerError)
}
// ignore normal prototypes for now xD
fn emit_log(args: &Vec<Address>, code: &mut Code)-> Result<Address, BuiltinEmitError> {
if args.len() == 1 {
return Result::Ok(code.push(Operation::Invoke(StdFunction:... | code_fim | hard | {
"lang": "rust",
"repo": "Tsuguri/octo",
"path": "/octo/src/tac_ir/emit_builtins.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tsuguri/octo path: /octo/src/tac_ir/emit_builtins.rs
use super::ir::{
Address,
ConstantValue,
Operation,
StdFunction,
};
use super::code::{Code};
use super::special_builtins as sb;
use sb::BuiltinEmitError;
pub fn emit_builtin(name: &str, args: &Vec<Address>, code: &mut Code)... | code_fim | hard | {
"lang": "rust",
"repo": "Tsuguri/octo",
"path": "/octo/src/tac_ir/emit_builtins.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!();
print!("test result: ");
if passed == 0 && failed == 0 {
print!("skipped");
} else if failed > 0 {
print!("failed");
} else {
print!("passed");
}
println!(
". {} passed; {} failed; {} skip... | code_fim | medium | {
"lang": "rust",
"repo": "SnakeSolid/rust-database-test",
"path": "/src/application/output/plain.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn case_skipped(&mut self, suite_name: &str, case_name: &str) {
println!("test {}::{} .. skipped", suite_name, case_name);
}
}
impl Default for PlainFormatter {
fn default() -> PlainFormatter {
PlainFormatter {}
}
}<|fim_prefix|>// repo: SnakeSolid/rust-database-test path... | code_fim | medium | {
"lang": "rust",
"repo": "SnakeSolid/rust-database-test",
"path": "/src/application/output/plain.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SnakeSolid/rust-database-test path: /src/application/output/plain.rs
use super::Formatter;
#[derive(Debug)]
pub struct PlainFormatter {}
impl Formatter for PlainFormatter {
fn header(&self) {
println!();
println!("running tests...");
println!();
}
fn footer... | code_fim | hard | {
"lang": "rust",
"repo": "SnakeSolid/rust-database-test",
"path": "/src/application/output/plain.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/meteora path: /meteora-proto/src/proto/commonpb.rs
// This file is generated by rust-protobuf 2.14.0. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(box_point... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/meteora",
"path": "/meteora-proto/src/proto/commonpb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_14_0;
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum State {
OK = 0,
WRONG_LEADER = 1,
NOT_FOUND = 2,
IO_ERROR = 3,
}
impl ::protobuf::Pr... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/meteora",
"path": "/meteora-proto/src/proto/commonpb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if found {
found_boards.insert(board_index);
let result = boards[board_index].iter().flatten().filter(|x| *x != &"Marked").map(|x| x.parse::<i32>().unwrap()).sum::<i32>();
last_scor... | code_fim | hard | {
"lang": "rust",
"repo": "hyb175/adventOfCode",
"path": "/2021/day4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hyb175/adventOfCode path: /2021/day4/src/main.rs
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::collections::HashSet;
fn read_lines<P>(filename: P) -> Result<Vec<String>, io::Error>
where P: AsRef<Path>, {
let file = File::open(filename)?;
io::BufReader::... | code_fim | hard | {
"lang": "rust",
"repo": "hyb175/adventOfCode",
"path": "/2021/day4/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: comit-network/secp256kfun path: /secp256kfun/src/marker/point_type.rs
use crate::{
backend::{self, BackendPoint, BackendXOnly},
marker::*,
op, Point, XOnly,
};
/// Every `T` of a [`Point<T,S,Z>`] implements the `PointType` trait.
///
/// There are several different point types.
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "comit-network/secp256kfun",
"path": "/secp256kfun/src/marker/point_type.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn norm_point_matches<T: Normalized, S>(point: &Point<T, S, NonZero>) -> bool {
op::NormPointUnary::is_y_square(point)
}
}
mod change_marks {
use crate::{marker::*, Point, XOnly};
impl<T, S, Z> ChangeMark<Point<T, S, Z>> for Normal {
type Out = Point<Normal, S, Z>;
... | code_fim | hard | {
"lang": "rust",
"repo": "comit-network/secp256kfun",
"path": "/secp256kfun/src/marker/point_type.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = A {a:Box::new(2)};
match a {
A {ref a} => {println!("{}", (*a).d);}
};
//after the match the filed a in A is borrowed
}<|fim_prefix|>// repo: MEM-Group/Rust-Semantics path: /rustsem-ocaml/rust_tests/pattern_matching/t5.rs
struct Box <T> {
d:T
}
impl Box <T> {
... | code_fim | medium | {
"lang": "rust",
"repo": "MEM-Group/Rust-Semantics",
"path": "/rustsem-ocaml/rust_tests/pattern_matching/t5.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MEM-Group/Rust-Semantics path: /rustsem-ocaml/rust_tests/pattern_matching/t5.rs
struct Box <T> {
d:T
}
impl Box <T> {
<|fim_suffix|> Box {d:x}
}
}
struct A {
a: Box < i32 >
}
fn main(){
let a = A {a:Box::new(1)};
match a {
A {a} => {println!("{}", a.d);... | code_fim | easy | {
"lang": "rust",
"repo": "MEM-Group/Rust-Semantics",
"path": "/rustsem-ocaml/rust_tests/pattern_matching/t5.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main(){
let a = A {a:Box::new(1)};
match a {
A {a} => {println!("{}", a.d);}
};
//after the match the filed a in A is moved
let a = A {a:Box::new(2)};
match a {
A {ref a} => {println!("{}", (*a).d);}
};
//after the match the filed a in A is borrowed
}<|fim_pref... | code_fim | medium | {
"lang": "rust",
"repo": "MEM-Group/Rust-Semantics",
"path": "/rustsem-ocaml/rust_tests/pattern_matching/t5.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn handle_client(stream: TcpStream) {
handle_read(&stream);
handle_write(stream);
}
fn main() {
let listener = TcpListener::bind("0.0.0.0:8080").unwrap();
println!("Listening for connections on port {}", 8080);
for stream in listener.incoming() {
match stream {
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "nanovms/nanos",
"path": "/test/e2e/rust/http_server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let listener = TcpListener::bind("0.0.0.0:8080").unwrap();
println!("Listening for connections on port {}", 8080);
for stream in listener.incoming() {
match stream {
Ok(stream) => {
thread::spawn(|| {
handle_client(stream)
... | code_fim | hard | {
"lang": "rust",
"repo": "nanovms/nanos",
"path": "/test/e2e/rust/http_server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nanovms/nanos path: /test/e2e/rust/http_server.rs
// Updated example from http://rosettacode.org/wiki/Hello_world/Web_server#Rust
// to work with Rust 1.0 beta
use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
<|fim_suffix|> let mut buf = [0u8 ;4096];
... | code_fim | medium | {
"lang": "rust",
"repo": "nanovms/nanos",
"path": "/test/e2e/rust/http_server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Queryable, Insertable)]
pub struct TaskModel {
pub task_id: String,
pub name: String,
pub time_limit: String,
}
impl TaskModel {
pub fn new(task: Task) -> TaskModel {
let task_id = format!("{}{}", &task.name, &task.time_limit.to_string());
return TaskModel ... | code_fim | medium | {
"lang": "rust",
"repo": "soichiro0311/microservice_rust",
"path": "/task_management/src/dto/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: soichiro0311/microservice_rust path: /task_management/src/dto/mod.rs
use super::schema::*;
use crate::domain::*;
use diesel::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct TaskDto {
pub name: String,
pub time_limit: String,
}
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "soichiro0311/microservice_rust",
"path": "/task_management/src/dto/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(r1, vec![1_3, 1_5]);
assert_eq!(r2, vec![1_4, 1_6]);
remove_children(&mut tx, 0, PREFIX, 1_2);
db.commit(tx).unwrap();
let r1: Vec<u32> = read_children(&*db, 0, PREFIX, 1_1).expect("(2) Getting r1 failed");
let r2: Vec<u32> = read_children(&*db, 0, PREFIX, 1_2).expect("(2) Getting... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/client/db/src/children.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use std::sync::Arc;
#[test]
fn children_write_read_remove() {
const PREFIX: &[u8] = b"children";
let db = Arc::new(sp_database::MemDb::default());
let mut tx = Transaction::new();
let mut children1 = Vec::new();
children1.push(1_3);
children1.push(... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/client/db/src/children.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /client/db/src/children.rs
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under ... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/client/db/src/children.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone,Copy)]
pub enum Value {
Van,
Normal
}<|fim_prefix|>// repo: hone/maximum_apocalypse_map_generator path: /src/board/tile.rs
use self::super::position::Position;
<|fim_middle|>#[derive(Clone,Copy)]
pub struct Tile {
pub value: Value,
pub position: Position,
}
| code_fim | medium | {
"lang": "rust",
"repo": "hone/maximum_apocalypse_map_generator",
"path": "/src/board/tile.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hone/maximum_apocalypse_map_generator path: /src/board/tile.rs
use self::super::position::Position;
<|fim_suffix|>#[derive(Clone,Copy)]
pub enum Value {
Van,
Normal
}<|fim_middle|>#[derive(Clone,Copy)]
pub struct Tile {
pub value: Value,
pub position: Position,
}
| code_fim | medium | {
"lang": "rust",
"repo": "hone/maximum_apocalypse_map_generator",
"path": "/src/board/tile.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/owo_colors/v3/crate/examples/supports_color.rs
use owo_colors::{OwoColorize, Stream::Stdout};
<|fim_suffix|> println!(
"{}",
"This will be red if viewed through a compatible terminal!"
.if_supports_color(Stdou... | code_fim | easy | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/owo_colors/v3/crate/examples/supports_color.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"{}",
"This will be red if viewed through a compatible terminal!"
.if_supports_color(Stdout, |x| x.red())
);
}<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/owo_colors/v3/crate/examples/supports_color.rs
use owo_colors::{OwoColo... | code_fim | easy | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/owo_colors/v3/crate/examples/supports_color.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let (x, y) = (1..500 as u32)
.cartesian_product(1..500)
.filter(|&(x, y)| x > y)
.filter(|&(x, y)| x.pow(2) + y.pow(2) == (1000 - x - y).pow(2))
.next()
.unwrap();
let answer = x * y * (1000 - x - y);
println!("{:?}", answer);
}<|fim_prefix|>... | code_fim | medium | {
"lang": "rust",
"repo": "ashfordneil/project_euler",
"path": "/src/p9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ashfordneil/project_euler path: /src/p9.rs
//! A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
//! a^2 + b^2 = c^2
//! For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
<|fim_suffix|> let (x, y) = (1..500 as u32)
.cartesian_product(1..500)
.filter(|&... | code_fim | medium | {
"lang": "rust",
"repo": "ashfordneil/project_euler",
"path": "/src/p9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pos.x < 0 || pos.y < 0 || pos.x >= self.width as i32 || pos.y >= self.height as i32 {
return Ok(());
}
self.draw_raw(
pos.x as u16,
pos.y as u16,
pos.x as u16,
pos.y as u16,
&[RawU16::from(color).into_inner... | code_fim | hard | {
"lang": "rust",
"repo": "h0gura/m5stack_hello_rust",
"path": "/src/ili9341/graphics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: h0gura/m5stack_hello_rust path: /src/ili9341/graphics.rs
use super::{Ili9341, Interface, OutputPin};
use core::fmt::Debug;
use embedded_graphics::{
drawable::Pixel,
geometry::{Point, Size},
pixelcolor::{
raw::{RawData, RawU16},
Rgb565,
},
primitives::Rectang... | code_fim | hard | {
"lang": "rust",
"repo": "h0gura/m5stack_hello_rust",
"path": "/src/ili9341/graphics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn size(&self) -> Size {
Size::new(self.width as u32, self.height as u32)
}
fn draw_pixel(&mut self, pixel: Pixel<Rgb565>) -> Result<(), Self::Error> {
let Pixel(pos, color) = pixel;
if pos.x < 0 || pos.y < 0 || pos.x >= self.width as i32 || pos.y >= self.height as i32... | code_fim | hard | {
"lang": "rust",
"repo": "h0gura/m5stack_hello_rust",
"path": "/src/ili9341/graphics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@ @lib.check_one_option_dropdown(answ, answ[ind])@<|fim_prefix|>// repo: bradunov/shkola path: /questions/equat_2/q00072/text.rs
Proveri da li je neki od parova @"(x,y)"@ rešenj<|fim_middle|>e datih jednačina.
@addition_table()@
@vspace@
Da li su jednačine ekvivalentne? @hspacept(10) | code_fim | medium | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/equat_2/q00072/text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradunov/shkola path: /questions/equat_2/q00072/text.rs
Proveri da li je neki od parova @"(x,y)"@ rešenj<|fim_suffix|>Da li su jednačine ekvivalentne? @hspacept(10)@ @lib.check_one_option_dropdown(answ, answ[ind])@<|fim_middle|>e datih jednačina.
@addition_table()@
@vspace@
| code_fim | easy | {
"lang": "rust",
"repo": "bradunov/shkola",
"path": "/questions/equat_2/q00072/text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> env_logger::init();
let address = "127.0.0.1:8080".parse().unwrap();
let server = hyper::server::Http::new()
.bind(&address, || Ok(Microservice {}))
.unwrap();
info!("Running microservice at {}", address);
server.run().unwrap();
}<|fim_prefix|>// repo: chanakaudaya/rust... | code_fim | hard | {
"lang": "rust",
"repo": "chanakaudaya/rust-learning-examples",
"path": "/rust_microservice/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chanakaudaya/rust-learning-examples path: /rust_microservice/src/main.rs
extern crate hyper;
extern crate futures;
#[macro_use]
extern crate log;
extern crate env_logger;
use hyper::server::{Request, Response, Service};
<|fim_suffix|>fn main() {
env_logger::init();
let address = "127.... | code_fim | hard | {
"lang": "rust",
"repo": "chanakaudaya/rust-learning-examples",
"path": "/rust_microservice/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn execute_visit(&mut self, model_cell: ModelCell) -> Result {
let applicable_nodes = {
let model = model_cell.borrow();
let iter = model.storage().iter();
let iter = iter.filter_map(|(id, cell)| {
self.is_applicable(*id, &*cell.borrow()).map(|h| {
(*id, cell.clo... | code_fim | hard | {
"lang": "rust",
"repo": "tuxmark5/north",
"path": "/north_core/src/compiler/pass.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tuxmark5/north path: /north_core/src/compiler/pass.rs
use {
crate::{
Node, NodeId,
compiler::{Compiler},
context::{ModelNodeId, ModelNodeRef},
model::ModelCell,
structure::StorageExt,
},
std::result,
};
//////////////////////////////////////////////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "tuxmark5/north",
"path": "/north_core/src/compiler/pass.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
pub type Result = result::Result<(), ()>;
////////////////////////////////////////////////////////////////////////////////////////////////<|fim_prefix|>// repo: tuxmark5/north path: /north... | code_fim | hard | {
"lang": "rust",
"repo": "tuxmark5/north",
"path": "/north_core/src/compiler/pass.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/scalable_cuckoo_filter path: /src/bits.rs
#[cfg(feature = "serde_support")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))]
pub struct Bits(#[cfg_attr(feature = "serde_support", serde(with = "serde_bytes"))... | code_fim | hard | {
"lang": "rust",
"repo": "sile/scalable_cuckoo_filter",
"path": "/src/bits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bits = Bits::new(12345);
assert_eq!(bits.len(), 12352);
assert_eq!(bits.get_uint(0, 1), 0);
bits.set_uint(0, 1, 1);
assert_eq!(bits.get_uint(0, 1), 1);
assert_eq!(bits.get_uint(333, 10), 0);
bits.set_uint(333, 10, 0b10_1101_0001);
a... | code_fim | medium | {
"lang": "rust",
"repo": "sile/scalable_cuckoo_filter",
"path": "/src/bits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whitequark/gimli path: /src/test_util.rs
#![allow(missing_docs)]
use crate::vec::Vec;
use crate::leb128;
use crate::Format;
use test_assembler::{Label, Section};
pub trait GimliSectionMethods {
fn sleb(self, val: i64) -> Self;
fn uleb(self, val: u64) -> Self;
fn initial_length(sel... | code_fim | hard | {
"lang": "rust",
"repo": "whitequark/gimli",
"path": "/src/test_util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn word_label(self, size: u8, val: &Label) -> Self {
match size {
4 => self.D32(val),
8 => self.D64(val),
_ => panic!("unsupported word size"),
}
}
}<|fim_prefix|>// repo: whitequark/gimli path: /src/test_util.rs
#![allow(missing_docs)]
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "whitequark/gimli",
"path": "/src/test_util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roxanewayve/ublox-core path: /src/interface/serial.rs
use super::DeviceInterface;
use crate::Error;
use embedded_hal as hal;
use shufflebuf::ShuffleBuf;
/// This encapsulates the Serial UART peripheral
/// and associated pins such as
/// - DRDY: Data Ready: Sensor uses this to indicate it had ... | code_fim | hard | {
"lang": "rust",
"repo": "roxanewayve/ublox-core",
"path": "/src/interface/serial.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn fill(&mut self) -> usize {
let mut fetch_count = self.shuffler.vacant();
let mut err_count = 0;
while fetch_count > 0 {
let rc = self.serial.read();
match rc {
Ok(byte) => {
err_count = 0; //reset
... | code_fim | hard | {
"lang": "rust",
"repo": "roxanewayve/ublox-core",
"path": "/src/interface/serial.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// `getauxval(AT_EXECFN)`—Returns the Linux "execfn" string.
///
/// Return the string that Linux has recorded as the filesystem path to the
/// executable.
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html
#[cfg(any(linux_raw, all(libc, any(targe... | code_fim | hard | {
"lang": "rust",
"repo": "Urgau/rsix",
"path": "/src/process/auxv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Urgau/rsix path: /src/process/auxv.rs
//! On mustang, the `init` function is unsafe because it operates on raw
//! pointers.
#![cfg_attr(target_vendor = "mustang", allow(unsafe_code))]
use crate::imp;
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
use std::ff... | code_fim | hard | {
"lang": "rust",
"repo": "Urgau/rsix",
"path": "/src/process/auxv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Initialize process-wide state.
#[cfg(target_vendor = "mustang")]
#[inline]
#[doc(hidden)]
pub unsafe fn init(envp: *mut *mut c_char) {
imp::process::init(envp)
}<|fim_prefix|>// repo: Urgau/rsix path: /src/process/auxv.rs
//! On mustang, the `init` function is unsafe because it operates on raw
//... | code_fim | hard | {
"lang": "rust",
"repo": "Urgau/rsix",
"path": "/src/process/auxv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: binh-vu/semantic-modeling path: /exec/src/main.rs
// `error_chain!` can recurse deeply
#![recursion_limit = "1024"]
extern crate mira;
extern crate algorithm;
extern crate rdb2rdf;
#[macro_use]
extern crate error_chain;
extern crate zmq;
#[macro_use]
extern crate serde_derive;
#[macro_use]
ex... | code_fim | hard | {
"lang": "rust",
"repo": "binh-vu/semantic-modeling",
"path": "/exec/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match app_m.subcommand() {
("exec_func", Some(sub_m)) => {
match sub_m.value_of("func").unwrap() {
"experiment::run_predict_fixed" => {
let mrr_model = experiment::load_model(&input, sub_m.value_of("model_file").unwrap());
exp... | code_fim | hard | {
"lang": "rust",
"repo": "binh-vu/semantic-modeling",
"path": "/exec/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msmithr/Chip8-Rust path: /src/processor/mod.rs
mod cpu;
mod fontset;
mod operation_map;
mod operations;
<|fim_suffix|>pub const CHIP8_WIDTH: u32 = 64;
pub const CHIP8_HEIGHT: u32 = 32;<|fim_middle|>#[cfg(test)]
mod operation_tests;
pub use self::cpu::Cpu;
| code_fim | medium | {
"lang": "rust",
"repo": "msmithr/Chip8-Rust",
"path": "/src/processor/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::cpu::Cpu;
pub const CHIP8_WIDTH: u32 = 64;
pub const CHIP8_HEIGHT: u32 = 32;<|fim_prefix|>// repo: msmithr/Chip8-Rust path: /src/processor/mod.rs
mod cpu;
mod fontset;
mod operation_map;
mod operations;
<|fim_middle|>#[cfg(test)]
mod operation_tests;
| code_fim | easy | {
"lang": "rust",
"repo": "msmithr/Chip8-Rust",
"path": "/src/processor/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: software-opal/thread-colors path: /src/generated/sulky_rayon_older.rs
8],
),
ThreadRef::new(
BRAND,
"1322",
"Crescent Moon",
&[129, 137, 1],
),
ThreadRef::new(
BRAND,
"1282",
"Tamarack",
&[146, 149, 3],
),
Th... | code_fim | hard | {
"lang": "rust",
"repo": "software-opal/thread-colors",
"path": "/src/generated/sulky_rayon_older.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: software-opal/thread-colors path: /src/generated/sulky_rayon_older.rs
ThreadRef::new(
BRAND,
"1200",
"Navy Blue",
&[20, 11, 45],
),
ThreadRef::new(
BRAND,
"1076",
"Velvet Morning",
&[90, 90, 139],
),
ThreadRef::new(... | code_fim | hard | {
"lang": "rust",
"repo": "software-opal/thread-colors",
"path": "/src/generated/sulky_rayon_older.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>AND,
"512",
"Tiger Eye",
&[178, 108, 41],
),
ThreadRef::new(
BRAND,
"1320",
"Gold/Orange",
&[199, 126, 35],
),
ThreadRef::new(
BRAND,
"614",
"Bark",
&[139, 30, 1],
),
ThreadRef::new(
BRA... | code_fim | hard | {
"lang": "rust",
"repo": "software-opal/thread-colors",
"path": "/src/generated/sulky_rayon_older.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therahulkanyal/funky path: /src/engine/mod.rs
!("OP_F64_CONST: pushing {} to stack", v);
self.store.stack.push(StackContent::Value(F64(*v)))
}
OP_F32_COPYSIGN => {
let (z1, z2) = fetch_binop!(self.store.stack);
... | code_fim | hard | {
"lang": "rust",
"repo": "therahulkanyal/funky",
"path": "/src/engine/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let outcome = self
.run_instructions(fr, &mut block_instructions.iter())
.with_context(|| {
format!("OP_LOOP({:?}) `run_instructions` failed", ty)
})?;
... | code_fim | hard | {
"lang": "rust",
"repo": "therahulkanyal/funky",
"path": "/src/engine/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therahulkanyal/funky path: /src/engine/mod.rs
tack);
convert!(self, v, I64, F32, f32, u64);
}
OP_F64_CONVERT_I64_U => {
let v = fetch_unop!(self.store.stack);
convert!(self, v, I64, F64, f64, u64);
... | code_fim | hard | {
"lang": "rust",
"repo": "therahulkanyal/funky",
"path": "/src/engine/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> already_updated_game_state_updates.insert(game_state_update.clone());
let did_win =
game_report.winning_player_index == game_state_update.responsible_player_index;
let mut is_in_cache = false;
let new_cache_value: (GameSt... | code_fim | hard | {
"lang": "rust",
"repo": "noahwillcrow/alpha-noah",
"path": "/src/game_state_records_providers/lru_cache_fronted_game_state_records_provider.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: noahwillcrow/alpha-noah path: /src/game_state_records_providers/lru_cache_fronted_game_state_records_provider.rs
use crate::structs::{
GameReport, GameStateRecord, GameStateUpdate, IncrementPersistedGameStateRecordValuesTask,
};
use crate::traits::{
BasicSerializedGameState, GameReportsP... | code_fim | hard | {
"lang": "rust",
"repo": "noahwillcrow/alpha-noah",
"path": "/src/game_state_records_providers/lru_cache_fronted_game_state_records_provider.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2021/day06/src/lib.rs
use std::fs;
use std::path::Path;
#[derive(Debug)]
pub struct Problem {
fish: [u64; 9],
}
impl Problem {
pub fn new<P: AsRef<Path>>(path: P) -> Self {
let mut fish = [0u64; 9];
<|fim_suffix|> Self { fish }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2021/day06/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(problem.part_one(), 5934);
}
#[test]
fn test_part_two() {
let problem = Problem::new("example.txt");
assert_eq!(problem.part_two(), 26984457539);
}
}<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2021/day06/src/lib.rs
use std::fs;
use std::p... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2021/day06/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn str_cpy(mut dst: *mut u8, mut s: *const u8) -> usize {
let mut count = 0;
while *s != 0 {
*dst = *s;
count += 1;
s = s.add(1);
dst = dst.add(1);
}
count
}<|fim_prefix|>// repo: archshift/crossbar9 path: /src/ffistr.rs
use core::slice;
pub uns... | code_fim | medium | {
"lang": "rust",
"repo": "archshift/crossbar9",
"path": "/src/ffistr.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.