text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let store = Store::default();
let module = Module::new(&store, &module_wat)?;
// The module doesn't import anything, so we create an empty import object.
let import_object = imports! {};
let instance = Instance::new(&module, &import_object)?;
let add_one = instance.exports.get_fun... | code_fim | hard | {
"lang": "rust",
"repo": "Tonyce/wasmer-project",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let add_one = instance.exports.get_function("add_one")?;
let result = add_one.call(&[Value::I32(42)])?;
assert_eq!(result[0], Value::I32(43));
Ok(())
}<|fim_prefix|>// repo: Tonyce/wasmer-project path: /src/main.rs
use wasmer::{imports, Instance, Module, Store, Value};
fn main() -> anyh... | code_fim | hard | {
"lang": "rust",
"repo": "Tonyce/wasmer-project",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /** Controls *how* the operation is perfomed. See the documentation for
* operation::Operation
*/
pub operation: Operation,
}
impl Default for Store {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}<|fim_prefix|>// repo: ApolloCrawler/gauc path: /src/couchbas... | code_fim | medium | {
"lang": "rust",
"repo": "ApolloCrawler/gauc",
"path": "/src/couchbase/types/cmd/store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ApolloCrawler/gauc path: /src/couchbase/types/cmd/store.rs
use super::super::key_buffer::KeyBuffer;
use super::super::operation::Operation;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct Store {
pub cmdflags: u32,
pub exptime: u32,
pub cas: u64,
pub key: KeyBuffer,
pub... | code_fim | medium | {
"lang": "rust",
"repo": "ApolloCrawler/gauc",
"path": "/src/couchbase/types/cmd/store.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::iter::FromIterator;
let id = String::from_iter(&self.id);
f.write_str(&id)
}
}
impl From<&str> for Id {
fn from(s: &str) -> Self {
Self { id: id(s) }
}
}<|fim_prefix|>// repo: ericrobolson/GoForthAndProsper path: /src/id.rs
const ID_SIZE: usize = 16;... | code_fim | hard | {
"lang": "rust",
"repo": "ericrobolson/GoForthAndProsper",
"path": "/src/id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.write_str(&id)
}
}
impl From<&str> for Id {
fn from(s: &str) -> Self {
Self { id: id(s) }
}
}<|fim_prefix|>// repo: ericrobolson/GoForthAndProsper path: /src/id.rs
const ID_SIZE: usize = 16; // Arbitrary
pub type Identifier = [char; ID_SIZE];
fn id(s: &str) -> Identifier {... | code_fim | hard | {
"lang": "rust",
"repo": "ericrobolson/GoForthAndProsper",
"path": "/src/id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ericrobolson/GoForthAndProsper path: /src/id.rs
const ID_SIZE: usize = 16; // Arbitrary
pub type Identifier = [char; ID_SIZE];
fn id(s: &str) -> Identifier {
<|fim_suffix|> use std::iter::FromIterator;
let id = String::from_iter(&self.id);
f.write_str(&id)
}
}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "ericrobolson/GoForthAndProsper",
"path": "/src/id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe_abomonate!(SargeContext : source_replica, dest_replica, pipe_stage, num_replicas, num_rtcs, is_rtc, is_march, start_time);<|fim_prefix|>// repo: murraydunne/cs848project path: /timely_experiment/src/sarge_context.rs
use timely::Data;
use std::clone::Clone;
use timely::ExchangeData;
use abomonatio... | code_fim | hard | {
"lang": "rust",
"repo": "murraydunne/cs848project",
"path": "/timely_experiment/src/sarge_context.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: murraydunne/cs848project path: /timely_experiment/src/sarge_context.rs
use timely::Data;
use std::clone::Clone;
use timely::ExchangeData;
use abomonation::Abomonation;
use std::time::Instant;
<|fim_suffix|>unsafe_abomonate!(SargeContext : source_replica, dest_replica, pipe_stage, num_replicas,... | code_fim | hard | {
"lang": "rust",
"repo": "murraydunne/cs848project",
"path": "/timely_experiment/src/sarge_context.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! spi_setup {
($spi:ident, $pclk:ident) => {
impl<SpiInt: drone_cortexm::thr::IntToken>
crate::NewSpiSetup<$spi, SpiInt, $pclk>
for crate::SpiSetup<$spi, SpiInt, $pclk>
{
fn new(
spi: drone_stm32_map::periph... | code_fim | hard | {
"lang": "rust",
"repo": "kaivol/drone-stm32f4-hal",
"path": "/src/spi/setup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaivol/drone-stm32f4-hal path: /src/spi/setup.rs
use drone_cortexm::thr::IntToken;
use drone_stm32f4_rcc_drv::{ConfiguredClk, clktree::PClkToken};
use drone_stm32_map::periph::spi::SpiPeriph;
pub use crate::{SpiMap, pins::*};
pub struct SpiSetup<Spi: SpiMap, SpiInt: IntToken, Clk: PClkToken> {... | code_fim | hard | {
"lang": "rust",
"repo": "kaivol/drone-stm32f4-hal",
"path": "/src/spi/setup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intech-id/collexi-rollup path: /core/server/tests/prover_server.rs
// Built-in deps
use std::{net, str::FromStr, thread, time, time::Duration};
// External deps
use crypto_exports::pairing::ff::{Field, PrimeField};
use futures::channel::mpsc;
// Workspace deps
use circuit::witness::{deposit::Dep... | code_fim | hard | {
"lang": "rust",
"repo": "intech-id/collexi-rollup",
"path": "/core/server/tests/prover_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let validator_acc = circuit_tree
.get(block.fee_account as u32)
.expect("fee_account is not empty");
let mut validator_balances = vec![];
for i in 0..total_tokens() {
let balance_value = match validator_acc.subtree.get(i as u32) {
None => models::node::Fr::z... | code_fim | hard | {
"lang": "rust",
"repo": "intech-id/collexi-rollup",
"path": "/core/server/tests/prover_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::sleep(time::Duration::from_secs(10));
// should return block
let to_prove = client
.block_to_prove(block_size_chunks)
.expect("failed to bet block to prove");
assert!(to_prove.is_some());
// block is taken unless no heartbeat from prover within prover_timeout ... | code_fim | hard | {
"lang": "rust",
"repo": "intech-id/collexi-rollup",
"path": "/core/server/tests/prover_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jianglibo/bk-over-ssh-yew path: /src/menu_block.rs
use crate::Scene;
use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, ShouldRender};
pub struct MainMenu {
props: Props,
link: ComponentLink<Self>,
}
pub enum Msg {
MenuItemClicked(Scene),
}
#[derive(Properties, C... | code_fim | hard | {
"lang": "rust",
"repo": "jianglibo/bk-over-ssh-yew",
"path": "/src/menu_block.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn change(&mut self, props: Self::Properties) -> ShouldRender {
js! {
console.log("props:" + @{props.active_scene.to_string()});
}
self.props = props;
true
}
fn view(&self) -> Html {
html! {
<div class="pure-menu">
... | code_fim | hard | {
"lang": "rust",
"repo": "jianglibo/bk-over-ssh-yew",
"path": "/src/menu_block.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let row_count = self.pixels.len();
let trimmed_pixels: Vec<Vec<_>> = (1..row_count - 1).map(|i| {
let row = self.row(i);
let row_length = row.len();
row[1..row_length - 1].iter().map(|p| *p).collect()
}).collect();
println!("Old dimension... | code_fim | hard | {
"lang": "rust",
"repo": "wenley/AdventOfCode2020",
"path": "/src/day20.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wenley/AdventOfCode2020 path: /src/day20.rs
extern crate regex;
use std::io;
use std::fs;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use regex::Regex;
fn main() {
let input = parse_input().unwrap();
let tile_to_unique_e... | code_fim | hard | {
"lang": "rust",
"repo": "wenley/AdventOfCode2020",
"path": "/src/day20.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn rotate_right(&self) -> Tile {
Tile {
identifier: self.identifier,
pixels: rotate_right(&self.pixels),
}
}
fn flip(&self) -> Tile {
Tile {
identifier: self.identifier,
pixels: vertical_axis_flip(&self.pixels),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "wenley/AdventOfCode2020",
"path": "/src/day20.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: woxtu/rust-httpstat path: /src/lib.rs
extern crate regex;
extern crate curl_sys;
extern crate libc;
extern crate clap;
extern crate rand;
pub mod httpstat;
pub mod curl;
pub use curl::easy::HttpVersion;
pub fn request(url: &str) -> Result<(curl::Response, curl::Time), String> {
let client... | code_fim | medium | {
"lang": "rust",
"repo": "woxtu/rust-httpstat",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match client.set_url(url) {
Err(e) => return Err(format!("{}", e)),
_ => {},
}
let response = client.perform();
match response {
Err(e) => return Err(format!("{}", e)),
_ => {},
}
let response = response.unwrap();
let time = client.get_time();
... | code_fim | hard | {
"lang": "rust",
"repo": "woxtu/rust-httpstat",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: birktj/dijkstra-controller-2019 path: /common/src/actuator.rs
use core::cell::{Cell, RefCell};
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal::timer::{CountDown, Periodic};
use embedded_hal::adc::{Channel, OneShot};
use embedded_hal::PwmPin;
use crate::adc::Adc;
#[derive(Eq... | code_fim | hard | {
"lang": "rust",
"repo": "birktj/dijkstra-controller-2019",
"path": "/common/src/actuator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn stop(&mut self) {
if self.state != State::Stop {
self.state = State::Stop;
self.update();
}
self.target = None;
}
pub fn go_fwd(&mut self) {
if self.state != State::Fwd && self.lim.is_high() {
self.state = State::Fwd;
... | code_fim | hard | {
"lang": "rust",
"repo": "birktj/dijkstra-controller-2019",
"path": "/common/src/actuator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hello {0}, My name is {1}.", "Peter", "Alice");
println!(
"Hello {name_1}, My name is {name_2}",
name_1="Peter",
name_2="Alice"
);
println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
let pi = 3.141592;
println!("Pi is roughl... | code_fim | easy | {
"lang": "rust",
"repo": "mangasf/rust-training",
"path": "/formatting/hello.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pi = 3.141592;
println!("Pi is roughly {:.3}", pi);
}<|fim_prefix|>// repo: mangasf/rust-training path: /formatting/hello.rs
fn main() {
println!("Hello World!");
println!("Hello World {}!", "Spain");
println!("Hello {0}, My name is {1}.", "Peter", "Alice");
<|fim_middle|> ... | code_fim | medium | {
"lang": "rust",
"repo": "mangasf/rust-training",
"path": "/formatting/hello.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mangasf/rust-training path: /formatting/hello.rs
fn main() {
println!("Hello World!");
println!("Hello World {}!", "Spain");
<|fim_suffix|> let pi = 3.141592;
println!("Pi is roughly {:.3}", pi);
}<|fim_middle|> println!("Hello {0}, My name is {1}.", "Peter", "Alice");
... | code_fim | hard | {
"lang": "rust",
"repo": "mangasf/rust-training",
"path": "/formatting/hello.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait DistributionParams {}
pub trait DiscreteDistribution<T: DistributionParams> {
fn pdf(&mut self, k: u64, distribution_params: &T) -> f64;
#[inline]
fn cdf(&mut self, k: u64, distribution_params: &T) -> f64 {
(0..k+1).fold(0f64, |sum, i| self.pdf(i, distribution_params) + sum... | code_fim | hard | {
"lang": "rust",
"repo": "markjunod/randomness",
"path": "/random_distributions/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markjunod/randomness path: /random_distributions/src/lib.rs
// Copyright (c) 2020 Mark Junod. Subject to the MIT License.
//! Traits defining random distributions, and utility methods to make accessing specific
//! implementations and functionality easier.
// TODO add documentation
pub mod pr... | code_fim | hard | {
"lang": "rust",
"repo": "markjunod/randomness",
"path": "/random_distributions/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[inline]
fn cdf(&mut self, k: u64, distribution_params: &T) -> f64 {
(0..k+1).fold(0f64, |sum, i| self.pdf(i, distribution_params) + sum)
}
}
pub trait ContinuousDistribution<T: DistributionParams> {
fn pdf(&mut self, x: f64, distribution_params: &T) -> f64;
fn cdf(&mut sel... | code_fim | hard | {
"lang": "rust",
"repo": "markjunod/randomness",
"path": "/random_distributions/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlueSkyT/rust-test path: /tests/first_test.rs
#[test]
fn f_test() {
assert_eq!(4, 5)
}
#[test]
fn f_test2() {
assert_eq!(4, 4)
}
#[test]
fn test_println() {
println!("{} days", 31)
}
#[test]
fn test_data_type() {
<|fim_suffix|> let s = [1, 2, 3, 4];
for i in s.iter() {
... | code_fim | hard | {
"lang": "rust",
"repo": "BlueSkyT/rust-test",
"path": "/tests/first_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", s.len());
let s1 = &s[0..2];
for i in s1.iter() {
println!("{}",i)
}
println!("test string");
let a = String::from("abcdef");
let as1 = &a[..];
let as2 = &a[1..3];
println!("as1:{}, as2:{}", as1, as2)
}<|fim_prefix|>// repo: BlueSkyT/rust-test pa... | code_fim | hard | {
"lang": "rust",
"repo": "BlueSkyT/rust-test",
"path": "/tests/first_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut mock = MockReactor::new();
mock.expect_react()
.with(eq(state))
.once()
.return_const(result);
let reactor: &mut dyn Reactor<_, Error = _> = &mut mock;
assert_eq!(reactor.react(&state), result);
}
}
#[cfg(test)]
pub(crate) ... | code_fim | hard | {
"lang": "rust",
"repo": "brunocodutra/reducer",
"path": "/src/reactor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[proptest]
fn react(state: u8, result: Result<(), u8>) {
let mut mock = MockReactor::new();
mock.expect_react()
.with(eq(state))
.once()
.return_const(result);
let reactor: &mut dyn Reactor<_, Error = _> = &mut mock;
assert_eq!... | code_fim | hard | {
"lang": "rust",
"repo": "brunocodutra/reducer",
"path": "/src/reactor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brunocodutra/reducer path: /src/reactor.rs
mod array;
#[cfg(feature = "alloc")]
mod boxed;
mod reference;
#[cfg(feature = "async")]
mod sink;
mod slice;
mod tuple;
#[cfg(feature = "async")]
pub use sink::AsyncReactor;
/// Trait for types that react to state transitions.
///
/// Reactors connec... | code_fim | hard | {
"lang": "rust",
"repo": "brunocodutra/reducer",
"path": "/src/reactor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ArtDark/sigchain path: /sigchain_core/src/crypto/secretbox.rs
use super::sodiumoxide::crypto::secretbox;
use super::sodiumoxide::init;
pub fn gen() -> Vec<u8> {
secretbox::gen_key().0.to_vec()
}
pub fn encrypt(plaintext: &[u8], symmetric_key: &[u8]) -> super::Result<Vec<u8>> {
init()?;... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_core/src/crypto/secretbox.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nonce_and_ciphertext : Vec<u8> = [nonce.0.as_ref().into(), ciphertext.as_slice()].concat();
Ok(EphemeralEncryption{
symmetric_key: key.0.as_ref().into(),
nonce_and_ciphertext,
})
}<|fim_prefix|>// repo: ArtDark/sigchain path: /sigchain_core/src/crypto/secretbox.rs
use supe... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_core/src/crypto/secretbox.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn ephemeral_encrypt(plaintext: Vec<u8>) -> super::Result<EphemeralEncryption> {
init()?;
let key = secretbox::gen_key();
let nonce = secretbox::gen_nonce();
let ciphertext = secretbox::seal(&plaintext, &nonce, &key);
let nonce_and_ciphertext : Vec<u8> = [nonce.0.as_ref().into(), ... | code_fim | hard | {
"lang": "rust",
"repo": "ArtDark/sigchain",
"path": "/sigchain_core/src/crypto/secretbox.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>trait T {
const CONST: i32;
}
const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST }
//[stock]~^ ERROR `?const` on trait bounds is experimental
//[stock,gated]~^^ ERROR `?const` on trait bounds is not yet implemented
fn main() {}<|fim_prefix|>// repo: Wind-River/rust path: /src/test/ui/... | code_fim | medium | {
"lang": "rust",
"repo": "Wind-River/rust",
"path": "/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wind-River/rust path: /src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs
// revisions: stock gated
// gate-test-const_trait_bound_opt_out
<|fim_suffix|>const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST }
//[stock]~^ ERROR `?const` on trait bounds is ... | code_fim | medium | {
"lang": "rust",
"repo": "Wind-River/rust",
"path": "/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn create_issue(issue: &JiraIssue, credential: &BaseAuthCredential) -> Result<String, Box<dyn std::error::Error>> {
let secret = credential.secret();
let reqeust_url = format!("{}/jiraify/issues",GIRHUBENDPOINR);
let client = reqwest::Client::new();
let mut map = HashMap::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "wear/jiraify",
"path": "/src/issue_controller.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wear/jiraify path: /src/issue_controller.rs
extern crate reqwest;
pub use crate::credential::{BaseAuthCredential};
use reqwest::header::{AUTHORIZATION, CONTENT_TYPE};
use serde_json::{Value};
use std::collections::HashMap;
use std::error::Error;
use std::fmt;
pub struct JiraIssue {
pub ti... | code_fim | hard | {
"lang": "rust",
"repo": "wear/jiraify",
"path": "/src/issue_controller.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liebharc/basic_dsp path: /vector/src/meta.rs
use super::vector_types::*;
/// Marker for types containing real data.
#[derive(Debug, Clone, PartialEq)]
pub struct Real;
impl NumberSpace for Real {
fn is_complex(&self) -> bool {
false
}
fn to_complex(&mut self) {}
fn to_re... | code_fim | hard | {
"lang": "rust",
"repo": "liebharc/basic_dsp",
"path": "/vector/src/meta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Marker for types containing time or frequency data.
#[derive(Debug, Clone, PartialEq)]
pub struct TimeOrFreq {
pub domain_current: DataDomain,
}
impl Domain for TimeOrFreq {
fn domain(&self) -> DataDomain {
self.domain_current
}
fn to_freq(&mut self) {
self.domain_curr... | code_fim | hard | {
"lang": "rust",
"repo": "liebharc/basic_dsp",
"path": "/vector/src/meta.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl core::fmt::Write for NIOConsole {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
unsafe {
ffi::nio_fputs(s.as_ptr(), self.ptr);
}
Result::Ok(())
}
}
impl core::ops::Drop for NIOConsole {
fn drop(&mut self) {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "JCRPaquin/rust-nspireio",
"path": "/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JCRPaquin/rust-nspireio path: /lib.rs
#![crate_name = "nspireio"]
#![crate_type = "rlib"]
#![feature(core, libc, collections, no_std)]
#![no_std]
extern crate core;
extern crate libc;
extern crate collections;
use libc::c_int;
use core::result::Result;
mod ffi {
use libc::{c_uchar, c_int... | code_fim | hard | {
"lang": "rust",
"repo": "JCRPaquin/rust-nspireio",
"path": "/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc176/src/bin/b.rs
use proconio::{input, marker::Bytes};
<|fim_suffix|> let mut x = 0_usize;
for n_i in n {
x += (n_i - b'0') as usize;
x %= 9;
}
let ans = x == 0;
println!("{}", if ans { "Yes" } else { "No" ... | code_fim | easy | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc176/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut x = 0_usize;
for n_i in n {
x += (n_i - b'0') as usize;
x %= 9;
}
let ans = x == 0;
println!("{}", if ans { "Yes" } else { "No" });
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc176/src/bin/b.rs
use proconio::{input, marker::Byte... | code_fim | easy | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc176/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> execute(&mut values);
assert_eq!(values, format_input("2,4,4,5,99,9801"));
}
#[test]
fn fourth_test() {
let mut values: Vec<usize> = format_input("1,1,1,4,99,5,6,0,99");
execute(&mut values);
assert_eq!(values, format_input("30,1,1,4,2,5,6,0,99"));
}<|fim_prefix|>// repo: alexander... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-jackson/aoc19",
"path": "/day2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexander-jackson/aoc19 path: /day2/src/main.rs
use std::fs;
fn format_input(input: &str) -> Vec<usize> {
input
.trim()
.split(',')
.filter(|x| !x.is_empty())
.map(|x| x.parse().unwrap())
.collect()
}
fn get_values(filename: &str) -> Vec<usize> {
... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-jackson/aoc19",
"path": "/day2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc308/src/bin/c.rs
use proconio::input;
fn main() {
input! {
n: usize,
ab: [(usize, usize); n],
};
let mut abi = ab
.iter()
.copied()
.enumerate()
.map(|(i, (a, b))| (a, b, i))
... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc308/src/bin/c.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>2),
std::cmp::Ordering::Greater => std::cmp::Ordering::Less,
},
);
for (_, _, i) in abi {
println!("{}", i + 1);
}
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc308/src/bin/c.rs
use proconio::input;
fn main() {
input! {
... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc308/src/bin/c.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut config = ServerConfig::builder()
.with_safe_defaults()
.with_client_cert_verifier(client_auth)
.with_single_cert_with_ocsp_and_sct(cert, key, self.ocsp_resp, Vec::new())
.map_err(TlsConfigError::InvalidKey)?;
config.alpn_protocols = v... | code_fim | hard | {
"lang": "rust",
"repo": "seanmonstar/warp",
"path": "/src/tls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanmonstar/warp path: /src/tls.rs
use std::fmt;
use std::fs::File;
use std::future::Future;
use std::io::{self, BufReader, Cursor, Read};
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, A... | code_fim | hard | {
"lang": "rust",
"repo": "seanmonstar/warp",
"path": "/src/tls.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theorlangur/format-column-rs path: /src/tests/test_xml.rs
#[cfg(test)]
mod mytests {
use crate::tests::mytests::run_analyzer as run_analyzer;
use crate::auto_config::*;
#[test]
fn test() {
<|fim_suffix|> //input
let in_str = r##"
<sometag prop1="val1" someotherpro... | code_fim | medium | {
"lang": "rust",
"repo": "theorlangur/format-column-rs",
"path": "/src/tests/test_xml.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = run_analyzer(in_str, cfg.analyzer.as_mut(), cfg.formatter, cfg.printer);
assert_eq!(result, out_str);
}
}<|fim_prefix|>// repo: theorlangur/format-column-rs path: /src/tests/test_xml.rs
#[cfg(test)]
mod mytests {
use crate::tests::mytests::run_analyzer as run_analyze... | code_fim | hard | {
"lang": "rust",
"repo": "theorlangur/format-column-rs",
"path": "/src/tests/test_xml.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let delegate = Delegate::new(to_server);
AppLauncher::with_window(main_window)
.delegate(delegate)
.configure_env(theme::apply)
.launch(state)
.expect("launch failed");
Ok(())
}<|fim_prefix|>// repo: Azorlogh/harmoxen path: /src/main.rs
use druid::{AppLauncher, LocalizedString, Size, WindowDe... | code_fim | hard | {
"lang": "rust",
"repo": "Azorlogh/harmoxen",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azorlogh/harmoxen path: /src/main.rs
use druid::{AppLauncher, LocalizedString, Size, WindowDesc};
#[macro_use]
mod util;
mod commands;
mod data;
mod server;
mod state;
mod theme;
mod ui;
mod widget;
use state::State;
mod delegate;
use delegate::Delegate;
fn main() -> Result<(), Box<dyn std::e... | code_fim | medium | {
"lang": "rust",
"repo": "Azorlogh/harmoxen",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> to_server
.send(server::Event::SetTempo(state.editors.sheet_editor.tempo))
.unwrap();
let main_window = WindowDesc::new(ui::build)
.title(LocalizedString::new("Harmoxen v0.2.0"))
.window_size(Size::new(800.0, 500.0));
let delegate = Delegate::new(to_server);
AppLauncher::with_window(main_wi... | code_fim | hard | {
"lang": "rust",
"repo": "Azorlogh/harmoxen",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/rust-protobuf-sgx path: /protobuf/src/json/mod.rs
//! JSON printer and parser which tries to follow
//! [protobuf conventions](https://developers.google.com/protocol-buffers/docs/proto3#json)
<|fim_suffix|>pub(crate) use self::json_name::json_name;
pub use self::parse::merge_from... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/rust-protobuf-sgx",
"path": "/protobuf/src/json/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) use self::json_name::json_name;
pub use self::parse::merge_from_str;
pub use self::parse::merge_from_str_with_options;
pub use self::parse::parse_dynamic_from_str;
pub use self::parse::parse_dynamic_from_str_with_options;
pub use self::parse::parse_from_str;
pub use self::parse::parse_from_str_... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/rust-protobuf-sgx",
"path": "/protobuf/src/json/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 9ary/rp2040-pac path: /src/pio0/fdebug.rs
#[doc = "Reader of register FDEBUG"]
pub type R = crate::R<u32, super::FDEBUG>;
#[doc = "Writer for register FDEBUG"]
pub type W = crate::W<u32, super::FDEBUG>;
#[doc = "Register FDEBUG `reset()`'s with value 0"]
impl crate::ResetValue for super::FDEBUG ... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/pio0/fdebug.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>d, so if this flag is set, your software has quite likely dropped some data on the floor."]
#[inline(always)]
pub fn txover(&self) -> TXOVER_R {
TXOVER_R::new(((self.bits >> 16) & 0x0f) as u8)
}
#[doc = "Bits 8:11 - RX FIFO underflow (i.e. read-on-empty by the system) has occurred.... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/pio0/fdebug.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/wosim path: /crates/database/src/cursor.rs
use std::mem::size_of;
use bytemuck::{cast_mut, cast_ref};
use crate::{
lock::Lock,
page::{Page, PageNr, NULL_PAGE_NR, PAGE_SIZE},
};
type IndirectPage = [PageNr; FAN_OUT as usize];
const FAN_OUT: usize = PAGE_SIZE / size_of::<PageNr... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wosim",
"path": "/crates/database/src/cursor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_pages(pages: usize) -> Option<Self> {
match pages {
0 => None,
1 => Some(Self::L0),
2..=2048 => Some(Self::L1),
2049..=4194304 => Some(Self::L2),
_ => panic!(),
}
}
pub const fn child(self) -> Option<Self>... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wosim",
"path": "/crates/database/src/cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn allocate_full(page_nr: &mut PageNr, level: PageLevel, lock: &Lock) {
let page = unsafe { lock.page_mut(page_nr) };
if level.is_indirect() {
let child_level = level.child().unwrap();
for page_nr in cast_mut::<Page, IndirectPage>(page).iter_mut() {
allocate_full(page_n... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wosim",
"path": "/crates/database/src/cursor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s the field bit"]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r" Clears the field bit"]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r" Writes raw bits to the field"]
#[inline]
pub fn bit(self, value: bool) -> &'a mut W {
... | code_fim | hard | {
"lang": "rust",
"repo": "andete/atsam4lc8c",
"path": "/src/usbc/udinteset/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andete/atsam4lc8c path: /src/usbc/udinteset/mod.rs
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::UDINTESET {
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "andete/atsam4lc8c",
"path": "/src/usbc/udinteset/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(LineNumber {
start_pc: start_pc,
line_number: line_number,
})
}
}
impl_print! {
LineNumber(self, printer) {
try!(write!(printer, "{:#x} = Line {}", self.start_pc, self.line_number));
}
}<|fim_prefix|>// repo: fossabot/rust-jvm-1 path: /class... | code_fim | medium | {
"lang": "rust",
"repo": "fossabot/rust-jvm-1",
"path": "/classfile/src/attr/info/code/line_number.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/rust-jvm-1 path: /classfile/src/attr/info/code/line_number.rs
use constant::ConstantPool;
use error::Result;
use std::slice::Iter;
#[derive(Debug)]
pub struct LineNumberTableAttrInfo {
entries: Vec<LineNumber>,
}
impl LineNumberTableAttrInfo {
pub fn entries<'a>(&'a self) -> I... | code_fim | medium | {
"lang": "rust",
"repo": "fossabot/rust-jvm-1",
"path": "/classfile/src/attr/info/code/line_number.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl_print! {
LineNumberTableAttrInfo(self, printer) {
for entry in self.entries() {
try!(printer.write_indent());
try!(entry.print(printer));
try!(writeln!(printer, ""));
}
}
}
#[derive(Debug)]
pub struct LineNumber {
pub start_pc: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/rust-jvm-1",
"path": "/classfile/src/attr/info/code/line_number.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juanramonduarte/mlua path: /tests/compile/non_send.rs
use std::cell::Cell;
use std::rc::Rc;
use mlua::{Lua, Result};
<|fim_suffix|> lua.create_function(move |_, ()| {
Ok(data.get())
})?
.call::<_, i32>(())?;
Ok(())
}<|fim_middle|>fn main() -> Result<()> {
let lua = ... | code_fim | medium | {
"lang": "rust",
"repo": "juanramonduarte/mlua",
"path": "/tests/compile/non_send.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> lua.create_function(move |_, ()| {
Ok(data.get())
})?
.call::<_, i32>(())?;
Ok(())
}<|fim_prefix|>// repo: juanramonduarte/mlua path: /tests/compile/non_send.rs
use std::cell::Cell;
use std::rc::Rc;
use mlua::{Lua, Result};
fn main() -> Result<()> {
<|fim_middle|> let lua = ... | code_fim | medium | {
"lang": "rust",
"repo": "juanramonduarte/mlua",
"path": "/tests/compile/non_send.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for child in c
{
new_children.push(convert_to_left(child)?);
}
ParseTreeNode::IfStatement(new_children)
},
ParseTreeNode::ReturnStatement(c) =>
{
let mut new_children = vec![];
for child in c
... | code_fim | hard | {
"lang": "rust",
"repo": "AshTS/LLVMCompiler",
"path": "/src/parser/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Close Paren
stream.expect_and_consume(String::from(")"))?;
Ok((stream, val))
}
else if let Ok(val) = parse_integer(&stream)
{
Ok(val)
}
else if let Ok(val) = parse_identifier(&st... | code_fim | hard | {
"lang": "rust",
"repo": "AshTS/LLVMCompiler",
"path": "/src/parser/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AshTS/LLVMCompiler path: /src/parser/parser.rs
_and_consume(String::from("++"))?;
current = ParseTreeNode::Expression(ExpressionType::PostIncrement, vec![current]);
}
// Post Decrement
else
{... | code_fim | hard | {
"lang": "rust",
"repo": "AshTS/LLVMCompiler",
"path": "/src/parser/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HectorIGH/Competitive-Programming path: /Leetcode Challenge/07_July_2020/Rust/Week 3/5_Add Binary.rs
//Given two binary strings, return their sum (also a binary string).
//
//The input strings are both non-empty and contains only characters 1 or 0.
//
//Example 1:
//
//Input: a = "11", b = "1"
/... | code_fim | hard | {
"lang": "rust",
"repo": "HectorIGH/Competitive-Programming",
"path": "/Leetcode Challenge/07_July_2020/Rust/Week 3/5_Add Binary.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while i >= 0 || j >= 0 || carry == 1 {
let mut sum : u8 = carry;
sum += if i >= 0 {A[i as usize] as u8 - 48} else {0};
sum += if j >= 0 {B[j as usize] as u8 - 48} else {0};
ans.push(if (sum & 1) == 1 {'1'} else {'0'});
carry = sum >> 1;
... | code_fim | medium | {
"lang": "rust",
"repo": "HectorIGH/Competitive-Programming",
"path": "/Leetcode Challenge/07_July_2020/Rust/Week 3/5_Add Binary.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hong4rc/deno path: /cli/ops/worker_host.rs
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::permissions::Permissions;
use crate::web_worker::run_web_worker;
use crate::web_worker::WebWorker;
use crate::web_worker::WebWorkerHandle;
use crate::web_worker::Work... | code_fim | hard | {
"lang": "rust",
"repo": "hong4rc/deno",
"path": "/cli/ops/worker_host.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
struct WorkerArgs {
id: i32,
}
fn op_host_terminate_worker(
state: &mut OpState,
args: Value,
_data: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
let args: WorkerArgs = serde_json::from_value(args)?;
let id = args.id as u32;
let worker_thread = state
.borrow... | code_fim | hard | {
"lang": "rust",
"repo": "hong4rc/deno",
"path": "/cli/ops/worker_host.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Spawn it
let join_handle = thread_builder.spawn(move || {
// Any error inside this block is terminal:
// - JS worker is useless - meaning it throws an exception and can't do anything else,
// all action done upon it should be noops
// - newly spawned thread exits
let worker = W... | code_fim | hard | {
"lang": "rust",
"repo": "hong4rc/deno",
"path": "/cli/ops/worker_host.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// translate intermediate code to Rust functions that can be called
build! { multiply [f32] f32 }
fn main() {
// a vector with elements of type f32
let initial_data = vec![3.7, 4.5, 9.0, 1.2, 8.9];
// call the multiply function written in Emu on the vector of data
let final_data = multiply(initial_... | code_fim | hard | {
"lang": "rust",
"repo": "0xflotus/emu",
"path": "/examples/multiply/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xflotus/emu path: /examples/multiply/src/main.rs
// This example has been taken from the OCL crate
// emu for writing code
extern crate em;
use em::emu;
use em::build;
// ocl for emu for packaging code in Rust functions that can be called
extern crate ocl;
use ocl::{flags, Platform, Device, C... | code_fim | hard | {
"lang": "rust",
"repo": "0xflotus/emu",
"path": "/examples/multiply/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Into<u32> for Lycian {
fn into(self) -> u32 {
let c: char = self.into();
let hex = c
.escape_unicode()
.to_string()
.replace("\\u{", "")
.replace("}", "");
u32::from_str_radix(&hex, 16).unwrap()
}
}
impl std::convert::Tr... | code_fim | hard | {
"lang": "rust",
"repo": "pierrechevalier83/unicode_types",
"path": "/src/generated/lycian.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unicode",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pierrechevalier83/unicode_types path: /src/generated/lycian.rs
/// An enum to represent all characters in the Lycian block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Lycian {
/// \u{10280}: '𐊀'
LetterA,
/// \u{10281}: '𐊁'
LetterE,
/// \u{10282}: '𐊂'
... | code_fim | hard | {
"lang": "rust",
"repo": "pierrechevalier83/unicode_types",
"path": "/src/generated/lycian.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unicode",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: byron7cueva/learn-rust path: /basics/hello-world-cargo/src/define-traits.rs
// Defining Traits
// Create the struct Person
struct Person {
name: String,
age: u8
}
// Create contract o interface
trait HasVoiceBox {
// Speak
fn speak(&self);
// Check if can speak
fn can_speak(&self) ... | code_fim | medium | {
"lang": "rust",
"repo": "byron7cueva/learn-rust",
"path": "/basics/hello-world-cargo/src/define-traits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let person = Person {
name: String::from("Byron"),
age: 30
};
println!("Can {} speak? {}", person.name, person.can_speak());
}<|fim_prefix|>// repo: byron7cueva/learn-rust path: /basics/hello-world-cargo/src/define-traits.rs
// Defining Traits
// Create the struct Person
struct Person {
... | code_fim | medium | {
"lang": "rust",
"repo": "byron7cueva/learn-rust",
"path": "/basics/hello-world-cargo/src/define-traits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: genusistimelord/Legion_Rune_Test path: /src/wrappers/legionwrap.rs
use legion::*;
use runestick::Any;
#[derive(Any)]
pub struct LegionWrap {
pub inner: legion::World,
}
impl LegionWrap {
pub fn new() -> Self {
Self {
inner: World::default(),
}
}
}
#[deriv... | code_fim | medium | {
"lang": "rust",
"repo": "genusistimelord/Legion_Rune_Test",
"path": "/src/wrappers/legionwrap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> module.ty::<LegionWrap>()?;
module.ty::<LegionEntityWrap>()?;
Ok(module)
}<|fim_prefix|>// repo: genusistimelord/Legion_Rune_Test path: /src/wrappers/legionwrap.rs
use legion::*;
use runestick::Any;
#[derive(Any)]
pub struct LegionWrap {
pub inner: legion::World,
}
impl LegionWrap {
... | code_fim | hard | {
"lang": "rust",
"repo": "genusistimelord/Legion_Rune_Test",
"path": "/src/wrappers/legionwrap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("visit_poly_trait_ref: st={:?}", self.st);
SawPolyTraitRef.hash(self.st);
m.hash(self.st);
visit::walk_poly_trait_ref(self, t, m)
}
fn visit_path_list_item(&mut self, prefix: &'tcx Path, item: &'tcx PathListItem) {
debug!("visit_path_list_item: st={:... | code_fim | hard | {
"lang": "rust",
"repo": "kosslab-kr/rust",
"path": "/src/librustc_incremental/calculate_svh/svh_visitor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kosslab-kr/rust path: /src/librustc_incremental/calculate_svh/svh_visitor.rs
=> SawExprCast,
ExprType(..) => SawExprType,
ExprIf(..) => SawExprIf,
ExprWhile(..) => SawExprWhile,
ExprLoop(_, id) => SawExprL... | code_fim | hard | {
"lang": "rust",
"repo": "kosslab-kr/rust",
"path": "/src/librustc_incremental/calculate_svh/svh_visitor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn visit_id(&mut self, id: NodeId) {
debug!("visit_id: id={} st={:?}", id, self.st);
self.hash_resolve(id)
}
fn visit_vis(&mut self, v: &'tcx Visibility) {
debug!("visit_vis: st={:?}", self.st);
SawVis.hash(self.st);
self.hash_discriminant(v);
v... | code_fim | hard | {
"lang": "rust",
"repo": "kosslab-kr/rust",
"path": "/src/librustc_incremental/calculate_svh/svh_visitor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "device-selected")]
use embedded_hal as hal;
#[cfg(feature = "stm32mp157")]
pub use stm32mp1::stm32mp157 as pac;
#[cfg(feature = "device-selected")]
#[deprecated(since = "0.6.0", note = "please use `pac` instead")]
#[doc(hidden)]
pub use crate::pac as device;
#[cfg(feature = "device-sel... | code_fim | hard | {
"lang": "rust",
"repo": "maximeborges/stm32mp1xx-hal",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maximeborges/stm32mp1xx-hal path: /src/lib.rs
//! # HAL for the STM32MP1 family of microcontrollers
//!
//! This is an implementation of the [`embedded-hal`] traits for the STM32MP1 family of
//! microcontrollers.
//!
//! [`embedded-hal`]: https://crates.io/crates/embedded-hal
//!
//! # Usage
//... | code_fim | hard | {
"lang": "rust",
"repo": "maximeborges/stm32mp1xx-hal",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TigerInYourDream/tikv path: /components/cdc/src/initializer.rs
},
Scanner::RawKvScanner(iter) => {
if iter.valid()? {
let key = iter.key();
let ts = ApiV2::decode_ts_from(key)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "TigerInYourDream/tikv",
"path": "/components/cdc/src/initializer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while !done {
// When downstream_state is Stopped, it means the corresponding
// delegate is stopped. The initialization can be safely canceled.
if self.downstream_state.load() == DownstreamState::Stopped {
return on_cancel();
}
... | code_fim | hard | {
"lang": "rust",
"repo": "TigerInYourDream/tikv",
"path": "/components/cdc/src/initializer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TigerInYourDream/tikv path: /components/cdc/src/initializer.rs
elf.observe_id;
let rts = resolver.resolve(TimeStamp::zero()).min();
info!(
"cdc resolver initialized and schedule resolver ready";
"region_id" => region.get_id(),
"conn_id" => ?sel... | code_fim | hard | {
"lang": "rust",
"repo": "TigerInYourDream/tikv",
"path": "/components/cdc/src/initializer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>lidOutputBase);
}
let mut num = 0;
for &d in number {
if d >= from_base {
return Err(Error::InvalidDigit(d));
}
num *= from_base;
num += d;
}
let mut vec = Vec::new();
while num > 0 {
vec.insert(0, num % to_base);
num /= t... | code_fim | medium | {
"lang": "rust",
"repo": "mraof/mraof-exercism-solutions",
"path": "/rust/all-your-base/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mraof/mraof-exercism-solutions path: /rust/all-your-base/src/lib.rs
#[derive(Debug, PartialEq)]
pub enum Error {
InvalidInputBase,
InvalidOutputBase,
InvalidDigit(u32),
}
pub fn convert(number: &[u32], from_base: u32, to_<|fim_suffix|>lidOutputBase);
}
let mut num = 0;
f... | code_fim | medium | {
"lang": "rust",
"repo": "mraof/mraof-exercism-solutions",
"path": "/rust/all-your-base/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/libm path: /src/math/j0.rs
/* origin: FreeBSD /usr/src/lib/msun/src/e_j0.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/libm",
"path": "/src/math/j0.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p: &[f64; 6];
let q: &[f64; 5];
let z: f64;
let r: f64;
let s: f64;
let mut ix: u32;
ix = get_high_word(x);
ix &= 0x7fffffff;
if ix >= 0x40200000 {
p = &PR8;
q = &PS8;
} else if ix >= 0x40122E8B {
p = &PR5;
q = &PS5;
} else i... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/libm",
"path": "/src/math/j0.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.