blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
7e40e415478731b60b8f3c3a7ae1e3ed28f5815c | Rust | l4l/systemd-journal-logger.rs | /tests/log_to_journal.rs | UTF-8 | 5,559 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright Sebastian Wiesner <sebastian@swsnr.de>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
/... | true |
69a885f4f600644cb114a56e852d8705e305cfca | Rust | nilq/tang | /src/wu/compiler/compiler.rs | UTF-8 | 8,206 | 3.21875 | 3 | [
"MIT"
] | permissive | use super::*;
#[derive(Debug, Clone)]
pub enum FlagImplicit {
Return,
Assign(String)
}
pub struct Generator {
flag: Option<FlagImplicit>
}
impl<'g> Generator {
pub fn new() -> Self {
Generator {
flag: None,
}
}
pub fn generate(&mut self, ast: &'g Vec<Statement>) -> String {
let m... | true |
6c9aea2639626832b61b6a4bbec66401f0e72ef3 | Rust | dorucioclea/omics | /publishing/application/publication/like.rs | UTF-8 | 3,903 | 2.6875 | 3 | [] | no_license | use common::event::EventPublisher;
use common::result::Result;
use crate::domain::interaction::InteractionService;
use crate::domain::publication::{PublicationId, PublicationRepository};
use crate::domain::reader::{ReaderId, ReaderRepository};
pub struct Like<'a> {
event_pub: &'a dyn EventPublisher,
publicat... | true |
be69ddc0e585784bae898334453347b5da5a1185 | Rust | TakaakiFuruse/rust-practice | /the_book/using_struct/src/main.rs | UTF-8 | 1,383 | 4.0625 | 4 | [] | no_license | #[derive(Debug)]
struct User {
name: String,
email: String,
sign_in_count: u64,
active: bool,
}
fn main() {
// === Structの使い方-====
let mut user1 = User {
// Using &str woudl be better, but need to use liftimes.
email: String::from("mail@mail.com"),
name: String::from("Na... | true |
826e0bbe1d73677233680804766e7871621bb5b0 | Rust | Deluvi/getwms | /src/webmention.rs | UTF-8 | 1,091 | 3.125 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::hash_map::Iter;
#[derive(Serialize, Debug)]
pub struct Author {
pub name : String,
pub url : String,
pub photo_url : String,
}
#[derive(Serialize, Debug)]
pub struct Webmention {
pub author : Author,
pub title : String,
pub content : String,... | true |
4bf687d49871c117bb33200e501840b8b784d75b | Rust | magiclen/validators | /validators/tests/signed_integer.rs | UTF-8 | 5,108 | 2.953125 | 3 | [
"MIT"
] | permissive | #![cfg(all(feature = "signed_integer", feature = "derive"))]
use validators::{prelude::*, validators_options::ValidatorRangeOption};
fn check_range<T: PartialOrd>(v: T, range: ValidatorRangeOption<T>) -> bool {
match range {
ValidatorRangeOption::Inside {
max,
min,
} => {
... | true |
6b2ff7ab5d78dc700cb79a8061c4745173a2a344 | Rust | wyyerd/stripe-rs | /bench/binary_size/src/main.rs | UTF-8 | 3,368 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | fn main() {
// Create a new client
let secret_key = std::env::var("STRIPE_SECRET_KEY").expect("Missing STRIPE_SECRET_KEY in env");
let client = stripe::Client::new(secret_key);
#[cfg(feature = "blocking")]
{
create_charge(&client);
create_customer(&client);
}
#[cfg(not(feat... | true |
11089a8ca5dc9140c89fd7b324b49136dc3ed601 | Rust | AndreasChristianson/project-euler-rust | /tests/pe-17.rs | UTF-8 | 1,415 | 4.15625 | 4 | [] | no_license | extern crate project_euler_rust;
use project_euler_rust::text::number_as_text::number_to_spoken_text;
/*
<p>If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.</p>
<p>If all the numbers from 1 to 1000 (one thousand) inclusive were wr... | true |
d73c30db31c9f2a9bcc053a08ea136bc692a54b1 | Rust | rust-lang/libm | /src/math/fma.rs | UTF-8 | 6,706 | 2.8125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::{f32, f64};
use super::scalbn;
const ZEROINFNAN: i32 = 0x7ff - 0x3ff - 52 - 1;
struct Num {
m: u64,
e: i32,
sign: i32,
}
fn normalize(x: f64) -> Num {
let x1p63: f64 = f64::from_bits(0x43e0000000000000); // 0x1p63 === 2 ^ 63
let mut ix: u64 = x.to_bits();
let mut e: i32 = (ix >> 5... | true |
15eeb82540aec277feaa7c682ba97a2377777f10 | Rust | NorabX/rustils | /src/impls/parse/double_impl.rs | UTF-8 | 1,452 | 3.375 | 3 | [
"MIT"
] | permissive | use parse::double::*;
impl ToF64 for bool {
/// Parse [`bool`](https://doc.rust-lang.org/std/primitive.bool.html) to
/// [`f64`](https://doc.rust-lang.org/std/primitive.f64.html)
/// (see more: [`bool_to_f64_res`](../../parse/double/fn.bool_to_f64_res.html))
///
/// # Examples
///
/// ```
... | true |
f17e82abfcd1040bb8f441e306dadda55d38e3c0 | Rust | zeroows/onitama | /onitamalib/src/gamemodes/multiplayer.rs | UTF-8 | 8,210 | 2.890625 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
use serde_cbor::{de, ser};
use wasm_bindgen::JsCast;
use wasm_bindgen::prelude::*;
use web_sys::MessageEvent;
use crate::gamemodes::base::Game;
use crate::GameView;
use crate::messages::GameMessage;
use crate::models::{Move, Player};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize)]
pub en... | true |
d7cad3989573f4328f6a4644d5d80069096d3faa | Rust | jlgerber/graphql_quckstart | /src/query.rs | UTF-8 | 1,131 | 2.734375 | 3 | [] | no_license |
use juniper::{
graphql_object, FieldError
};
use crate::{Database, User};
#[derive(Clone, Copy, Debug)]
pub struct Query;
#[graphql_object(context = Database)]
/// Query data from the users db
impl Query {
/// Retrieve users
async fn users(context: &Database, name: Option<String>) -> Vec<User> {
... | true |
4b4f6e65e426322c65724dcdb8fe4c537d2fed93 | Rust | d-smith/notes | /solana/quests/quest1/hello-world/src/main.rs | UTF-8 | 1,305 | 4.25 | 4 | [] | no_license | fn main() {
// type inference
let x = "hello, world";
println!("{}",x);
// mutable
let mut y = 4;
println!("y is {}",y);
y = 5;
println!("y is {}",y);
// explicit typing types
let a:i32 = 2;
println!("a is {}", a);
// tuples
let b = (1, 3.14, "xxx", 'x', true);
... | true |
cc05192bd4798867c2e9c2a54e6c359f351f9c32 | Rust | makepad/makepad | /libs/zune-jpeg/src/color_convert/avx.rs | UTF-8 | 10,038 | 2.5625 | 3 | [
"MIT"
] | permissive | /*
* Copyright (c) 2023.
*
* This software is free software;
*
* You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license
*/
//! AVX color conversion routines
//!
//! Okay these codes are cool
//!
//! Herein lies super optimized codes to do color conversions.
//!
//!
//! 1. The... | true |
146434fc1155f0f700a63856fee6e0b711a92edd | Rust | insertt/switch | /src/opt.rs | UTF-8 | 1,597 | 3.34375 | 3 | [] | no_license | use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "switch", author = "", about = "Switch between environment variables in current session easily.")]
pub enum SwitchCommand {
#[structopt(name = "set")]
/**
* Set environment variable in given category.
* Note: It will cre... | true |
4d593aafe59fed6b6d77cec4ec3fac1fb00bdd9e | Rust | IThawk/rust-project | /rust-master/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs | UTF-8 | 1,116 | 3.703125 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use std::ops::{Index, IndexMut};
struct Foo {
x: isize,
y: isize,
}
impl<'a> Index<&'a String> for Foo {
type Output = isize;
fn index(&self, z: &String) -> &isize {
if *z == "x" {
&self.x
} else {
&self.y
}
}
}
impl<'a> IndexMut<&'a String> for Fo... | true |
84fe0ee81bf30716126bb74c43149ed44da0ef7e | Rust | faern/adventofcode2020 | /src/bin/day6_1.rs | UTF-8 | 622 | 2.78125 | 3 | [] | no_license | fn main() {
let input_path = std::env::args_os()
.skip(1)
.next()
.expect("Specify input as arg 1");
let input = std::fs::read_to_string(input_path).expect("Failed to read input");
let mut sum: u32 = 0;
for group_questions in input.split("\n\n") {
let mut yes_answers = [... | true |
6c25103287235fcb891ba8fe6980b3729c7f7698 | Rust | clouds56/atasks | /src/core.rs | UTF-8 | 3,366 | 2.890625 | 3 | [] | no_license | use std::pin::Pin;
use futures::{Stream, Future};
#[derive(Debug, Clone)]
pub struct Progress {
pub current: usize,
pub completed: usize,
pub failed: usize,
pub processed: Option<usize>,
pub total: usize,
}
#[derive(Debug)]
pub struct State {
pub idx: usize,
pub items: usize, // success_items + failed_... | true |
5525a2b9f6c96a565e3fa3fd4b4c8e5848201ce8 | Rust | austinabell/rust-error-stuff | /boxing_error/src/lib.rs | UTF-8 | 1,956 | 3.609375 | 4 | [] | no_license | use std::error::Error;
use std::fmt;
type BoxResult<T> = std::result::Result<T, Box<dyn Error>>;
#[derive(Debug, Clone)]
struct NoStringGiven;
impl fmt::Display for NoStringGiven {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "you need to give a string to convert!")
}
}
impl Erro... | true |
e9299b4621b615b43ab88e1611982860a317e1df | Rust | gauteh/ambiq-apollo3-pac | /src/vcomp/cfg/mod.rs | UTF-8 | 20,507 | 2.5625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CFG {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W... | true |
04dbca91e004109fff433fa86f2edcbdf750da51 | Rust | thealexhoar/radium | /src/game/ui/console_system.rs | UTF-8 | 1,884 | 2.71875 | 3 | [
"MIT"
] | permissive | use ecs::{ComponentManager, PassiveSystem, Space};
use graphics::{DrawTarget, GlyphBatch, RGBColor, Tile, Window};
use game::Blackboard;
pub struct ConsoleSystem {
_draw_target: DrawTarget,
_center_draw_target: DrawTarget,
_width: u32,
_height: u32,
_window_x: u32,
_window_y: u32
}
impl Consol... | true |
43448ab20febf412a4fa31ad85756a74f958ee39 | Rust | chasestarr/segment-chess-board | /src/debug.rs | UTF-8 | 1,098 | 2.6875 | 3 | [] | no_license | use image::{GrayImage, RgbImage, RgbaImage};
use std::fs;
use std::path::Path;
pub fn debug_images() -> bool {
return std::env::var("DEBUG").is_ok();
}
pub fn write_gray(i: &GrayImage, name: &str) {
if debug_images() {
let output_dir = Path::new("./tmp");
if !output_dir.is_dir() {
fs::create_dir(out... | true |
4223186fe6431b7c055c1532f1831fcd4f215875 | Rust | Bingwen-Hu/hackaway | /books/TRPL/medium/cp11_test/adder/src/lib.rs | UTF-8 | 234 | 2.859375 | 3 | [
"BSD-2-Clause"
] | permissive | #[cfg(test)]
mod tests {
#[test]
fn exploration() {
assert_eq!(2 + 2, 4);
}
// #[test]
// fn fail() {
// panic!("make this function fails");
// }
}
pub fn add_two(x: i32) -> i32 {
x + 2
} | true |
e5f03f251fbec5223309eac9f3e1513c481f0f69 | Rust | AntonGepting/tmux-interface-rs | /src/target/target_window_tests.rs | UTF-8 | 1,907 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #[test]
fn target_window_ex() {
use crate::{TargetWindow, TargetWindowExt, TargetWindowToken};
let _target_window = TargetWindowExt {
..Default::default()
};
let target_window = TargetWindowExt {
session: None,
window: Some(TargetWindow::Token(TargetWindowToken::Start)),
};... | true |
b340ea3b1f42eaceb0864a937ba291c869364859 | Rust | extrawurst/gitui | /src/components/utils/logitems.rs | UTF-8 | 4,217 | 2.828125 | 3 | [
"MIT"
] | permissive | use asyncgit::sync::{CommitId, CommitInfo};
use chrono::{DateTime, Duration, Local, NaiveDateTime, Utc};
use indexmap::IndexSet;
use std::{rc::Rc, slice::Iter};
#[cfg(feature = "ghemoji")]
use super::emoji::emojifi_string;
static SLICE_OFFSET_RELOAD_THRESHOLD: usize = 100;
type BoxStr = Box<str>;
pub struct LogEntr... | true |
556aed874debd51e7b1571bdbd667abd835783fa | Rust | twking7/adventofcode2017 | /src/day1.rs | UTF-8 | 939 | 3.765625 | 4 | [] | no_license | fn summer(num: &str, rotate: usize) -> usize {
let d1: Vec<usize> = num
.chars()
.map(|c| c.to_string().parse::<usize>().unwrap())
.collect();
let mut d2 = d1.clone();
d2.rotate(rotate);
d1.iter()
.zip(d2.iter())
.filter(|&(x, y)| x == y)
.map(|(x, _)| x... | true |
63da3a4b8934565817179e46517c11db5df586ca | Rust | Dante-Broggi/swift-bindgen | /swift-rt/src/ctx_desc/base.rs | UTF-8 | 6,862 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use crate::ctx_desc::{
ContextDescriptorFlags, ContextDescriptorKind, ExtensionContextDescriptor,
ModuleContextDescriptor, ProtocolContextDescriptor, TypeContextDescriptor,
};
use std::{fmt, hint, ptr};
use swift_sys::{
ctx_desc::ContextDescriptor as RawContextDescriptor, ptr::RelativeIndirectablePointer,
}... | true |
528339ea48fc059c094cbd1d1b1ef123b72263d5 | Rust | ryutah/rust-tutorials | /select-sample/src/main.rs | UTF-8 | 875 | 3.140625 | 3 | [] | no_license | #![feature(mpsc_select)]
use std::io::stdin;
use std::sync::mpsc;
use std::thread;
use std::time;
fn main() {
let after = time_after(5);
let input = read_input_async();
println!("Please input something within 5 seconds passed...");
select! {
s = input.recv() => println!("Input is {}", s.unwr... | true |
2831a992b941170c226d4c23ca5de190f5f79e4d | Rust | Yesterday17/SNLCompiler | /snl-utils/src/token.rs | UTF-8 | 2,931 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive | use std::str::FromStr;
use std::fmt::{Display, Formatter};
#[repr(C)]
#[derive(Debug, Clone)]
pub struct Token {
pub token_type: TokenType,
pub image: String,
pub line: u32,
pub column: u32,
}
impl Display for Token {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}... | true |
681f13e5bfa754dba7e91fb61629d29a90b66747 | Rust | dkijania/rust-bdd | /src/api/utils/reflection.rs | UTF-8 | 448 | 3.234375 | 3 | [] | no_license | use serde::Serialize;
/// returns value of object field as string
///
/// # Arguments
///
/// * 'obj' - target struct which should have expected field
/// * 'name' - field name
pub fn get_value<T: Serialize>(obj: T, name: &str) -> String {
let text = serde_json::to_string(&obj).unwrap();
let value: serde_json:... | true |
9022342fdde3138cd1d6da43440893fc8aebbcf7 | Rust | jiehuali/polars | /polars/polars-lazy/src/physical_plan/expressions/take.rs | UTF-8 | 3,817 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::physical_plan::state::ExecutionState;
use crate::prelude::*;
use polars_core::frame::groupby::GroupTuples;
use polars_core::prelude::*;
use std::sync::Arc;
pub struct TakeExpr {
pub(crate) phys_expr: Arc<dyn PhysicalExpr>,
pub(crate) idx: Arc<dyn PhysicalExpr>,
pub(crate) expr: Expr,
}
impl Tak... | true |
7e1de4a017238ee6c15f38e5ad94dcbcf0076fc1 | Rust | liuefng/orderbook-rs | /src/bin/example.rs | UTF-8 | 2,779 | 2.96875 | 3 | [
"MIT"
] | permissive |
extern crate orderbook;
use std::time::SystemTime;
use orderbook::{Orderbook, OrderSide, orders};
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum BrokerAsset {
USD,
EUR,
BTC,
ETH,
}
fn parse_asset(asset: &str) -> Option<BrokerAsset> {
match asset {
"USD" => Some(BrokerAsset::USD)... | true |
beb54838d3842dccf1df6a990cf10aea11b8d594 | Rust | bridger-herman/wasm-raytracer | /src/lights/directional_light.rs | UTF-8 | 1,531 | 3.515625 | 4 | [] | no_license | //! Directional light. Simulates a star-like light.
use crate::camera::Camera;
use crate::intersection::Intersection;
use crate::lights::light::Light;
use crate::material::Material;
use crate::pixel::Pixel;
use crate::vector::Vector3;
#[derive(Debug)]
pub struct DirectionalLight {
pub color: Pixel,
pub direct... | true |
263b67c54224ef61abf3777d46ba049e46b408e2 | Rust | nakakura/webrtc_gateway_controller | /example/peer.rs | UTF-8 | 4,070 | 2.578125 | 3 | [
"MIT"
] | permissive | mod terminal;
use std::env;
use futures::channel::mpsc;
use futures::prelude::*;
use futures::*;
use log::info;
use skyway_webrtc_gateway_api::peer::PeerEventEnum;
use skyway_webrtc_gateway_api::prelude::*;
use skyway_webrtc_gateway_api::*;
#[derive(Debug)]
struct PeerFoldParameters((Option<PeerInfo>, Vec<mpsc::Send... | true |
fa8ec9c2bc65c1fba39310bb9ae81eb31760e914 | Rust | yaxollum/problem-tracker | /src/main.rs | UTF-8 | 643 | 2.65625 | 3 | [
"MIT"
] | permissive | use problem_tracker::{run, RunResult};
use std::io;
fn main() {
let stdin = io::stdin();
match run(stdin.lock()) {
RunResult::Report(report) => println!("{}", report),
RunResult::ParseError { line_num, line } => {
eprintln!("Could not parse line {}: \"{}\"", line_num, line);
... | true |
a629907602101de74d174cbfb2674c6a557f4332 | Rust | atsamd-rs/atsamd | /hal/src/thumbv7em/can.rs | UTF-8 | 4,163 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! This module provides target specific integration with the [`mcan`] crate.
//!
//! MCAN is an off-the-shelf peripheral that is synthesized and integrated
//! into, among the others, E51/E54 MCUs.
//!
//! Instance of the [`Dependencies`] struct is necessary in order to make `mcan`
//! abstractions operational.
//!
//... | true |
af5f628161977c37882a3760b7791ba76d645333 | Rust | aharpole/adventofcode-2019 | /src/days/day11.rs | UTF-8 | 2,877 | 2.75 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | use crate::common::Solution;
use crate::intcode::IntcodeComputer;
use std::collections::HashMap;
type Point = (i64, i64);
fn run(computer: IntcodeComputer, white_panels: HashMap<Point, bool>) -> HashMap<Point, bool> {
fn get_input(white_panels: &HashMap<Point, bool>, pos: &Point) -> Option<i64> {
Some(if ... | true |
5f5878b1c6ff9821c401b5155355f7724c748a7c | Rust | kadtewsd/mandelbrot | /src/parsing/mod.rs | UTF-8 | 890 | 3.65625 | 4 | [] | no_license | use ::std::str::FromStr;
/// parse the string s as as coordinate pair, like 400x600 or 1.0.0.5
///
fn parse_pair<T: FromStr>(s: &str, separator: char) -> Option<(T, T)> {
println!("hoge");
match s.find(separator) {
None => None,
Some(index) => {
match (T::from_str(&s[..index]), T::fr... | true |
beefdff2e1ec1ac2b4def47455827783819e615b | Rust | nyctef/tcui | /src/main.rs | UTF-8 | 6,022 | 2.53125 | 3 | [] | no_license | mod teamcity;
use teamcity::{download_build, Build, BuildStatus};
mod git;
use git::get_current_branch;
use crossterm::{
event::{self, Event as CEvent, KeyCode},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use std::{
env,
io::{stdout, Writ... | true |
c29767b973525d31d62d1927ad74326f6bba9298 | Rust | akusumoto/work | /rust/code_golf/primenumber1.rs | UTF-8 | 96 | 2.640625 | 3 | [] | no_license | fn main(){for n in 2..101{let mut p=1;for i in 2..n{if n%i==0{p=0;}}if p==1{println!("{}",n)}}}
| true |
e6ab4e89b5464d003f8ea558157d780dde9c1c1c | Rust | dsp6414/rust-notebook | /general/rust-practice/src/trait_extend_types.rs | UTF-8 | 396 | 3.234375 | 3 | [] | no_license | #![allow(dead_code)]
trait Sum<T> {
fn sum(&self) -> i32;
}
impl Sum<i32> for Vec<i32> {
fn sum(&self) -> i32 {
let mut results: i32 = 0;
for item in self {
results += item;
}
results
}
}
pub fn trait_extend_types_test() {
let myvector: Vec<i32> = vec![1,2... | true |
fab4f8a0ac24cfc09e6804fa56b705d890dc18a2 | Rust | pczarn/panini | /panini_codegen/src/output/instruction.rs | UTF-8 | 4,665 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use enum_coder::enum_coder;
use panini_logic::middle::ir::Ir;
use panini_logic::output::instruction::Instruction;
use rs;
pub struct LowerInstructionList {
pub list: Vec<LowerInstruction>,
}
enum_coder! {
pub enum LowerInstruction {
Concat(usize),
ConcatSeparated(usize, rs::TokenStream),
... | true |
147a9a2e5823fb43dd552f345806b37169a76bff | Rust | stefanoc/advent2020 | /src/bin/day5.rs | UTF-8 | 1,244 | 3.21875 | 3 | [] | no_license | // FFBBBFFRRL
fn lower_half(r: (u8, u8)) -> (u8, u8) {
(r.0, r.0 + (r.1 - r.0 + 1) / 2)
}
fn upper_half(r: (u8, u8)) -> (u8, u8) {
(r.0 + ((r.1 - r.0 + 1) / 2), r.1)
}
fn seek(i: char, r: (u8, u8)) -> (u8, u8) {
match i {
'F' | 'L' => lower_half(r),
'B' | 'R' => upper_half(r),
_ =... | true |
e28a5c969481ad75b3b2246d65ffcd653c229b04 | Rust | yoshuawuyts/scan-fonts | /src/font_style.rs | UTF-8 | 257 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /// Font style
#[derive(Debug, Clone)]
pub enum FontStyle {
/// Default font style.
Normal,
/// Thick.
Bold,
/// Slanted.
Italic,
/// Crossed out.
Oblique,
}
impl Default for FontStyle {
fn default() -> Self {
FontStyle::Normal
}
}
| true |
6df3c078bf2630fca748ea1c437c8eadc0058e6f | Rust | raphaelcohn/security-keys-rust | /workspace/security-keys-rust/src/low_level/iso_7816_6_tag_length_value/TagLengthValue.rs | UTF-8 | 3,560 | 2.84375 | 3 | [
"MIT"
] | permissive | // This file is part of security-keys-rust. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/raphaelcohn/security-keys-rust/master/COPYRIGHT. No part of security-keys-rust, including this file, may be copied, modified... | true |
b08919269c7d6a3e15b25eb1af927215aeb15ca6 | Rust | barrucadu/lambdamoo | /rust-source/src/parse_cmd.rs | UTF-8 | 3,761 | 3.34375 | 3 | [
"LicenseRef-scancode-mit-specification-disclaimer"
] | permissive | extern crate libc;
use std::mem::size_of;
use ascii_string::{AsciiString, c_str_to_ascii_str};
use memory::{MemoryType, almost_mymalloc, rs_str_to_c_str};
/// Split a string into space-separated words, where:
///
/// - Leading spaces are ignored: ` hello world` is [`hello`,`world`]
/// - Multiple spaces are merged: ... | true |
9c4302b2f0b51082194fab1c738982714285bf03 | Rust | mesalock-linux/crates-sgx | /vendor/unicode-normalization/src/normalize.rs | UTF-8 | 5,126 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | true |
064f49d87be297a49f1ddc12315c9d6d17a1035f | Rust | gotham-rs/gotham | /gotham/src/router/tree/segment.rs | UTF-8 | 1,207 | 3.125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Defines `SegmentType` for `Tree`.
use std::collections::HashMap;
use crate::helpers::http::PercentDecoded;
use crate::router::tree::regex::ConstrainedSegmentRegex;
/// Mapping of segment names into the collection of values for that segment.
pub type SegmentMapping<'r> = HashMap<&'r str, Vec<&'r PercentDecoded>>;
... | true |
2c8afa3028c566db3a01b351893b03c454ae6ff7 | Rust | WorryingWonton/rust-bat | /src/doubleX.rs | UTF-8 | 591 | 3.15625 | 3 | [] | no_license | #[allow(non_snake_case)]
fn doubleX(s: String) -> bool {
for i in 0..s.len() {
if s.chars().nth(i).unwrap() == 'x' {
if i + 1 < s.len() && s.chars().nth(i+1).unwrap() == 'x' {
return true;
}
return false;
}
}
return false;
}
fn main() {
... | true |
073eb0d5e292d9f7d39ce1ee29794e9a687848ac | Rust | nlanson/rail-network | /src/math/segment.rs | UTF-8 | 3,294 | 3.53125 | 4 | [] | no_license | #![allow(non_snake_case, dead_code)]
/**
Segment Struct:
Stores the Seg struct and relevent methods.
*/
//Dependencies
use crate::{
Point2,
pt2,
Pow,
math::Equation,
math::util
};
pub struct Seg {
pub start: Point2,
pub end: Point2,
pub eq: Equation
}
//Enum for distinguishing ... | true |
a2e76801b549dfa152db6a1d5c91e48407f9bc35 | Rust | hulsizer/advent_of_code_2020 | /src/day3/mod.rs | UTF-8 | 2,148 | 3.78125 | 4 | [] | no_license |
#[derive(Debug)]
struct Point {
x: usize,
y: usize,
}
impl std::fmt::Display for Point {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "x: {}, y: {}", self.x, self.y)
}
}
struct Traversal {
position: Point,
slope: Point,
trees_hit: usize,
}
impl Trave... | true |
cf8dea583408222119e591e50f80ad49ee6ea2fc | Rust | chrisquion/city-is-ogre | /src/sentience/action.rs | UTF-8 | 846 | 2.96875 | 3 | [] | no_license | #[derive(Eq, PartialEq, Debug, Clone)]
pub enum AiAction {
/// There's a lot going behind the scenes
ZoneOut,
/// Wander aimlessly
Wander,
/// Navigate to the destination for the given reason
GottaGoTo {
target: WorldPoint,
reason: &'static str,
},
/// Go pickup the (1... | true |
b36aeeac2ebbb6159faf9cdb89baa860e4bfe965 | Rust | KnudiDudi/nees | /emulator/src/bitfield.rs | UTF-8 | 4,274 | 3.109375 | 3 | [
"MIT"
] | permissive | macro_rules! bitfield {
( $name:ident<$field_type:ty> ($( $field:ident: $lower:literal..$upper:literal ),*)) => {
#[allow(non_snake_case)]
pub mod $name {
#[derive(Default, PartialEq, Debug, Eq)]
pub struct Fields {
bits: $field_type,
$(pub $fi... | true |
413e182b955360991a1b9ff337af9443f3fd7988 | Rust | dvc94ch/hashgraph | /src/state/transaction.rs | UTF-8 | 3,015 | 2.828125 | 3 | [
"ISC"
] | permissive | use crate::author::{Author, Signature};
use crate::error::Error;
use serde::{de::Error as SerdeError, Deserialize, Deserializer, Serialize, Serializer};
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum Transaction {
AddAuthor(Author, u64),
RemAuthor(Author, u64),
SignBlock(Signature)... | true |
12c60cdc43179284a2b2b0f7e782a0ea427d41ff | Rust | yozeff/Rust | /sorting/src/main.rs | UTF-8 | 2,140 | 3.3125 | 3 | [] | no_license | //Joseph Harrison 2019
//bubble sort
use std::io;
mod quick_sort;
fn bubble_sort(mut xs: Vec<i32>) -> Vec<i32> {
//tracks if swaps have been performed
let mut swaps: bool = true;
let mut round: u32 = 1;
while swaps == true {
println!("round {}", round);
//at the b... | true |
42c96ff64f4c262b7f8f8ebcce4c624a0d7b4690 | Rust | Krankdud/chat-display | /src/twitch.rs | UTF-8 | 2,452 | 2.90625 | 3 | [
"MIT"
] | permissive | use futures::prelude::*;
use hex::FromHex;
use irc::client::prelude::*;
use irc::proto::message::Tag;
use rand::prelude::*;
use std::sync::mpsc::Sender;
pub enum TwitchCommand {
ClearChat {
user: Option<String>,
},
ClearMsg {
id: String,
},
Message {
id: String,
user... | true |
7c56c394fb85e64ec6905cb074e15ba39baaf588 | Rust | atakurt/iyzipay-rust | /src/model/sub_merchant.rs | UTF-8 | 24,875 | 2.53125 | 3 | [] | no_license | use std::fmt;
use bigdecimal::BigDecimal;
use log::debug;
use crate::client::HttpClient;
use crate::model::PaymentItem;
use crate::options::Options;
use crate::requests::CreateApmInitializeRequest;
use crate::requests::CreateApprovalRequest;
use crate::requests::CreateSubMerchantRequest;
use crate::requests::PKISeria... | true |
a57e880607fb7640b6438e3ba0ca917a1171113e | Rust | cs2dsb/game-Dec19 | /src/components/velocity.rs | UTF-8 | 1,351 | 3.03125 | 3 | [
"MIT"
] | permissive | use amethyst::{
ecs::{Component, DenseVecStorage},
core::math::{
Vector2,
Rotation2,
Unit,
},
};
use crate::util::math::radians;
use rand::random;
union Transmute<T: Copy, U: Copy> {
from: T,
to: U,
}
const X_AXIS: Unit<Vector2<f32>> = unsafe {
Transmute::<[f32; 2], Uni... | true |
145aec2a96ed9d216a8a4669bdf2dc0a24cb66a5 | Rust | blumu/travnorm | /rust/src/ast.rs | UTF-8 | 2,218 | 3.609375 | 4 | [] | no_license | /// Various AST representations of lambda terms
/// parameterized by a 'name referencing type' `T`.
/// Variable identifier used to declare names in lambda nodes
pub type Identifier = String;
/// A standard AST for lambda terms where consecutive lambda nodes can be combined
/// into a single abstraction node.
/// Typ... | true |
49f8cd0e25547aa9f8fea6d2cf983cc044af2377 | Rust | jakyle/pathfinding-grid | /src/direction.rs | UTF-8 | 1,523 | 3.453125 | 3 | [] | no_license | #[derive(Clone, PartialEq, Eq, Hash)]
pub enum Direction {
NW,
N,
NE,
W,
E,
SW,
S,
SE,
U,
D,
UNW,
UN,
UNE,
UW,
UE,
USW,
US,
USE,
DNW,
DN,
DNE,
DW,
DE,
DSW,
DS,
DSE,
}
impl Direction {
pub fn get_opposite(&self) ... | true |
5d36ff32744e0ef3662d87f500554aac11f22e50 | Rust | NathanaelLane/adler | /src/lib.rs | UTF-8 | 11,319 | 3.34375 | 3 | [
"0BSD",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Adler-32 checksum implementation.
//!
//! This implementation features:
//!
//! - Permissively licensed (0BSD) clean-room implementation.
//! - Zero dependencies.
//! - Decent performance (3-4 GB/s).
//! - `#![no_std]` support (with `default-features = false`).
#![doc(html_root_url = "https://docs.rs/adler/0.2.2")... | true |
c7f7690340b16e99f078e4e6f21ace117084288d | Rust | hisham24/image_labeler | /tests/tests.rs | UTF-8 | 26,916 | 2.5625 | 3 | [] | no_license | use std::net::TcpListener;
use std::collections::HashMap;
use sqlx::{PgConnection, Connection, PgPool, Executor};
use image_labeler::startup::run;
use image_labeler::configuration::{get_configuration, DatabaseSettings};
use uuid::Uuid;
use image_labeler::data::{Metadata, ImageLabels, SavedImages, UserRequest};
use std:... | true |
80e3fa4f74cece95a30a74edfbb068e09a2a2789 | Rust | kwaegel/include2dot | /src/find_includes.rs | UTF-8 | 11,201 | 2.859375 | 3 | [
"MIT"
] | permissive |
use std::io::{self, Read};
use std::fs::File;
use std::path::{Path, PathBuf};
use std::ffi::OsString;
use std::error::Error;
use std::collections::HashSet;
use walkdir::WalkDir;
use regex::Regex;
use itertools::Itertools;
use file_node::FileNode;
use hash_graph::HashGraph;
use super::*;
// -------------------------... | true |
44365b47df9176e737430f5a26b2aec943464a4e | Rust | cetusDownfall/exercises | /exercises/rust-exercises/flatmaptest/src/main.rs | UTF-8 | 238 | 2.65625 | 3 | [] | no_license | fn main() {
let vect = vec![
vec![0, 1, 2, 3],
vec![4, 5, 6, 7],
vec![8, 9, 10, 11],
vec![12, 13, 14, 15]];
println!("{:?}", vect.into_iter().flat_map(|it| it.into_iter()).collect::<Vec<i32>>());
}
| true |
b681678e7943795275921180189012cea5d4d005 | Rust | cocomoff/open-data-structure-rust-basic | /src/main.rs | UTF-8 | 1,088 | 3.796875 | 4 | [] | no_license | use std::ops::Index;
struct ArrayStack<T> {
array: Vec<T>,
n: usize
}
impl<T> ArrayStack<T> {
pub fn new() -> Self {
// 配列のnew(C++)ではなく空ベクタで実装
ArrayStack{array:Vec::new(), n:0}
}
fn size(&self) -> usize { self.n }
fn get(&self, i: usize) -> &T { &self.array[i] }
fn set(&mut... | true |
0a2c4d1bcdc6ba584400ef37392918084de4e493 | Rust | laxect/kosmos | /aoi/src/request.rs | UTF-8 | 1,051 | 3.265625 | 3 | [
"MIT"
] | permissive | use std::cmp::PartialEq;
use structopt::StructOpt;
#[derive(Clone, Debug, StructOpt, PartialEq)]
pub(crate) enum Item {
Add { name: Vec<String> },
Remove { name: Vec<String> },
List,
Clear,
}
#[derive(Clone, Debug, StructOpt, PartialEq)]
pub(crate) enum Request {
Keyword(Item),
Page(Item),
}
... | true |
ba9eb2eaf5fd9a941b729013bcd550ec431062fd | Rust | gnoliyil/fuchsia | /src/testing/sl4f/src/factory_reset/types.rs | UTF-8 | 603 | 2.546875 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2020 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.
/// Enum for supported Factory reset commands.
pub enum FactoryResetMethod {
FactoryReset,
}
impl std::str::FromStr for FactoryResetMethod {
type ... | true |
02c59d6d0d9128b33caba8e0842d56ef75cd5794 | Rust | sigbbe/codewars | /src/cw_13_07_2021/fibo_akin.rs | UTF-8 | 1,925 | 3.640625 | 4 | [
"MIT"
] | permissive | // Written by: https://www.codewars.com/users/AurevoirXavier
/**
* Given two numbers n, k (integers > 2). The function
* returns the number of terms u[i] >= k with 1 <= i <= n.
* If we look above we can see that between u[1] and u[23]
* we have four u[i] greater or equal to 12:
* length_sup_u_k(23, 12) => 4 ... | true |
3419857b8eec365f5ba1b74cdb5873ddd8ac3b73 | Rust | zaksky7/Rust-project | /src/year2019/day14.rs | UTF-8 | 2,208 | 3 | 3 | [] | no_license | use ahash::AHashMap;
use num::integer::div_mod_floor;
use std::cmp::max;
type Reactions<'a> = AHashMap<&'a str, (i64, Vec<(i64, &'a str)>)>;
fn parse_reactions(input: &str) -> Reactions {
input
.lines()
.map(|line| {
let pts = line.split(" => ").collect::<Vec<_>>();
let inp... | true |
c56ddde6e54047da2363d2ae16b7c40a49ce018a | Rust | HeroicKatora/automata | /src/nondeterministic.rs | UTF-8 | 9,120 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::num::NonZeroUsize;
use std::ops::Range;
use super::{Alphabet, Ensure};
use super::deterministic::{self, Deterministic};
pub struct NonDeterministic<A> {
/// All visited characters, ordered.
characters: Vec<A>,
/// The edges of all nodes.
edges: Vec<Edge>,
... | true |
16b421f463bbcc72989f742e67e950955cde77d9 | Rust | khanhtc1202/undefined-rust | /tests/tests.rs | UTF-8 | 917 | 3.359375 | 3 | [] | no_license | /// NOTE: When you run multiple tests, by default they run in parallel using threads.
/// if you don't want tests run in parallel use following command
/// > cargo test -- --test-threads=1
/// use `#[ignore]` attribute to make some tests be ignored while run tests
/// specific run ignored tests by using
/// > cargo te... | true |
41fb59d009b8fec4741f4335d78eabedbe438d7f | Rust | udoprog/OxidizeBot | /crates/oxidize-chat/src/messages.rs | UTF-8 | 2,979 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashMap;
use std::future::Future;
use std::pin::pin;
use std::sync::Arc;
use anyhow::Result;
use tokio::sync::{RwLock, RwLockReadGuard};
use tracing::Instrument;
use common::stream::{StreamExt, StreamMap};
#[derive(Debug, Clone, Copy)]
pub struct Optional {
id: &'static str,
}
#[derive(Deb... | true |
c33b32dad355b4fdac175ba57844bd4374bd72bc | Rust | mimblewimble/grin | /store/tests/lmdb.rs | UTF-8 | 4,819 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... | true |
341b211d4d37fac7e3f3b1420029ad00a9e0c296 | Rust | DelSkayn/rquickjs | /core/src/loader/native_loader.rs | UTF-8 | 1,935 | 2.53125 | 3 | [
"MIT"
] | permissive | use crate::{
loader::util::check_extensions, module::ModuleData, module::ModuleLoadFn, Ctx, Error, Result,
};
use super::Loader;
/// The native module loader
///
/// This loader can be used as the nested backing loader in user-defined loaders.
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "dyn-load")))]
#[der... | true |
45eb6557b4b45e8cda0e3631568faea8824457ef | Rust | MakeBigStory/gl_helpers_mobile | /src/gl_framebuffer.rs | UTF-8 | 4,159 | 2.53125 | 3 | [
"MIT"
] | permissive | #![allow(unused_imports)]
use gles;
use gles::es20::data_struct::*;
use gles::es20::wrapper::*;
use gles::es20::ffi::*;
use gles::es30::ffi::*;
use gles::es30::wrapper::*;
use super::{Attachment, GLTexture};
#[derive(Debug, Hash)]
pub struct GLFramebuffer {
id: GLuint,
}
impl GLFramebuffer {
#[inline(always... | true |
88502f8de7eebed559c7d34fcb48a23e677cea66 | Rust | nateglims/actix-wasm-example | /frontend/crate/src/lib.rs | UTF-8 | 1,509 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use backend::Data;
use futures::{future, Future};
use js_sys::Promise;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::future_to_promise;
use wasm_bindgen_futures::JsFuture;
use web_sys::{Request, RequestInit, RequestMode, Response};
#[wasm_bindgen]
pub fn run() -> Promise {
let m... | true |
a3ff12a8b9c49d6592262c3778c81e302123b081 | Rust | viperscape/lichen | /tests/unit.rs | UTF-8 | 11,601 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | extern crate lichen;
use lichen::parse::{Parser,Block,SrcBlock,Map};
use lichen::logic::{Logic,Expect};
use lichen::var::{Var,Mut};
use lichen::source::{Src,Next};
use lichen::eval::Evaluator;
use std::collections::HashMap;
#[test]
fn parse_block() {
let src = "root\n
@root.some_item \"Thing\"\n
unequip... | true |
e6034f02d1d9c38ffcaa3028076a2f6886edc32f | Rust | brianquinlan/learn-machine-learning | /gradient-descent-impl/src/main.rs | UTF-8 | 2,165 | 3.234375 | 3 | [
"MIT"
] | permissive | extern crate rand;
use rand::{thread_rng, Rng};
use rand::distributions::{IndependentSample, Normal};
fn main() {
let mut rng = thread_rng();
// Initialize the feature matrix.
let mut x = [[0.0; 4]; 1000];
for i in 0..x.len() {
let xi = [
1.0,
// Choosing a larger ran... | true |
2cc95747c7ab4ca364319a94bc220d9a37acd345 | Rust | yukimura1227/trainings | /rust_training/projects/hello_world/main.rs | UTF-8 | 167 | 2.875 | 3 | [
"MIT"
] | permissive | // https://doc.rust-jp.rs/book-ja/ch01-02-hello-world.html
// rustc main.rs
// ./main
fn main() {
// 世界よ、こんにちは
println!("Hello, world!");
}
| true |
7eab7a7def3519787b8fbc120a4fe5ce40a957d6 | Rust | mfelsche/http-types | /src/headers/header_name.rs | UTF-8 | 5,086 | 3.578125 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::borrow::Cow;
use std::fmt::{self, Debug, Display};
use std::str::FromStr;
use crate::Error;
/// A header name.
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct HeaderName(Cow<'static, str>);
impl HeaderName {
/// Create a new `HeaderName` from a Vec of ASCII bytes.
///
/// # Error
///
//... | true |
78faa9d203000065dda98cf832c2fcf7c35e9d0c | Rust | jakyle/rust-algos | /src/merge_trees.rs | UTF-8 | 3,406 | 3.5 | 4 | [
"MIT"
] | permissive | use std::{cell::RefCell, rc::Rc};
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
type Node = Option<Rc<RefCell<TreeNode>>>;
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
Tr... | true |
eb7a349602a2e36341baf1fba713ad3a175b2238 | Rust | multiojuice/chip8_retargeter_llvm | /emulator/src/main.rs | UTF-8 | 1,917 | 2.921875 | 3 | [] | no_license | /**
* main.rs
* this is the main file that should handle the main emulator loop.
* This loop includes the following:
* 1) Polling input
* 2) Running on Cycle of the CPU
* 3) Updating graphics (if needed)
* 4) Updating timer registers
* 5) Controlling execution rate of your emulator, (Hz... | true |
e7c062ce87be11c19d5f1419579b50f2ff41080d | Rust | kowaalczyk/latte | /src/meta/location_meta.rs | UTF-8 | 540 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::meta::Meta;
/// metadata type for location data (used by generated parser)
#[derive(Debug, PartialEq, Clone)]
pub struct LocationMeta {
/// byte offset from the beginning of source code
pub offset: usize,
}
impl From<usize> for LocationMeta {
fn from(offset: usize) -> Self {
Self { offs... | true |
ed56cf5a559051e6bd7088d8ce29eabe9f905ac1 | Rust | foxfriends/paper-terminal | /src/printer.rs | UTF-8 | 30,134 | 2.546875 | 3 | [] | no_license | use crate::str_width;
use crate::table::Table;
use crate::termpix;
use crate::words::Words;
use ansi_term::Style;
use console::AnsiCodeIterator;
use image::{self, GenericImageView as _};
use pulldown_cmark::{Alignment, CodeBlockKind, Event, Tag};
use std::convert::{TryFrom, TryInto};
use std::io::{Read as _, Write as _... | true |
1b2c11c5fc7af7c9e1882259d99406aa9e5ae953 | Rust | caryhaynie/rust_os | /Kernel/Core/lib/queue.rs | UTF-8 | 2,247 | 2.859375 | 3 | [
"BSD-2-Clause"
] | permissive | //
//
//
use _common::*;
pub struct Queue<T>
{
pub head: OptPtr<QueueEnt<T>>,
pub tail: OptMutPtr<QueueEnt<T>>,
}
pub struct QueueEnt<T>
{
next: OptPtr<QueueEnt<T>>,
value: T
}
pub struct Items<'s, T: 's>
{
cur_item: Option<&'s QueueEnt<T>>,
}
pub struct ItemsMut<'s, T: 's>
{
cur_item: OptMutPtr<QueueEnt<T>>,
... | true |
cb8ff9e92b3fb3ef1b6613c355e1737bdd637a21 | Rust | rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust | /Chapter 6/cctype.rs | UTF-8 | 1,488 | 3.28125 | 3 | [] | no_license | // cctype.rs -- use char
use std::io;
use std::io::prelude::*;
fn main() -> io::Result<()> {
let mut stdout: io::Stdout = io::stdout();
let mut stdin: io::Stdin = io::stdin();
let _: usize = stdout.write(b"Enter text for analysis, and type #")?;
let _: usize = stdout.write(b" to terminate input.\n")?... | true |
8f26b05c86bb176598738a61339d2927510f8308 | Rust | balintbalazs/advent-of-code-2020 | /src/bin/day2.rs | UTF-8 | 1,401 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use advent_of_code_2020::read_lines;
use scan_fmt::scan_fmt;
fn main() -> Result<(), Box<dyn Error>> {
let mut valid = (0, 0);
for line in read_lines("inputs/day2_in.txt")? {
if let Ok(line) = line {
if check_rule1(&line) {
valid.0 = valid.0 + 1;
... | true |
62a7948f4d77183c7631c64facd4efa41afa4628 | Rust | firebirdljk/grab-stock-bigdata | /examples/pull_month_data_from_tencent_to_postgre.rs | UTF-8 | 3,374 | 2.75 | 3 | [] | no_license | use tokio_postgres::{NoTls, Error};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let (client, connection) =
tokio_postgres::connect("host=localhost user=postgres dbname=firebird_stock", NoTls).await?;
tokio::spawn(async move {
if let Err(e) = connecti... | true |
7df863e79230b6f1c457428eaee1f43176046914 | Rust | ThijsRay/AdventOfCode | /2019/original/src/day7.rs | UTF-8 | 3,749 | 2.953125 | 3 | [] | no_license | use crate::day5;
use aoc_runner_derive::{aoc, aoc_generator};
use permutohedron::heap_recursive;
#[aoc_generator(day7)]
pub fn generator(input: &str) -> Vec<isize> {
day5::generator(input)
}
#[aoc(day7, part1)]
pub fn part1(input: &Vec<isize>) -> isize {
let mut phase_settings = [0, 1, 2, 3, 4];
let mut p... | true |
7cf61947d8693ff1f5b7a16000190fa156c0673a | Rust | tommyshem/learn-to-code | /learn-rustlang/coding-exercises/rust-examples/control-flow/src/main.rs | UTF-8 | 660 | 3.9375 | 4 | [] | no_license | mod if_let;
mod if_let_else;
enum Coin {
Penny,
Nickel,
Dime,
Quarter,
}
fn value_in_cents(coin: Coin) -> u8 {
match coin {
Coin::Penny => 1,
Coin::Nickel => 5,
Coin::Dime => 10,
Coin::Quarter => 25,
}
}
fn value_to_string(some_u8_value: u8) {
match some_u8... | true |
c838ccf49a83978fc1be139bd1032120530f69f3 | Rust | hacspec/hacspec | /lib/src/bigint_integers.rs | UTF-8 | 6,844 | 3.484375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![allow(unused_variables)]
use crate::prelude::*;
impl Integer for BigInt {
/// `NUM_BITS` is arbitrary for `BigInt`, so this i `0`.
const NUM_BITS: usize = 0;
#[inline]
#[cfg_attr(feature = "use_attributes", not_hacspec)]
fn ZERO() -> Self {
BigInt::from(0)
}
#[inline]
#[cfg_... | true |
a6befaff013cc6d513fd3fb7e2b9277289be718f | Rust | subscript-publishing/subscript-display | /src/error.rs | UTF-8 | 2,016 | 2.875 | 3 | [] | no_license | // use crate::lexer::Token;
use std::fmt;
use crate::font::{AtomType};
use crate::ast::symbols::Symbol;
pub type LayoutResult<T> = ::std::result::Result<T, LayoutError>;
pub type ParseResult<'a, T> = ::std::result::Result<T, ParseError<'a>>;
#[derive(Debug, Clone, PartialEq)]
pub enum LayoutError {
Font(FontError... | true |
edc2df39f70a73bf32c4a951cf2230142ce7903d | Rust | sogapalag/contest | /atcoder/abc161/e.rs | UTF-8 | 3,756 | 2.8125 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufRea... | true |
ff0627ffc9b8e2f976162f0ed7d11d920de279e2 | Rust | sinkingpoint/dot-notes | /backend/src/routes/api/models.rs | UTF-8 | 4,403 | 2.59375 | 3 | [] | no_license | use crate::db::{DBError, DBSchedule, DBScheduleToInsert};
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use warp::reject::Reject;
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum NoteContents {
Note(String),
Block(Vec<NoteContents>),
}
#[derive(Serialize, Deseriali... | true |
69128955880dd34dad88fe1199c5c58c30dc2540 | Rust | allenk/hdr10plus_parser | /src/hdr10plus/mod.rs | UTF-8 | 1,246 | 2.828125 | 3 | [
"MIT"
] | permissive | use indicatif::{ProgressBar, ProgressStyle};
use std::{fs::File, path::Path};
pub mod metadata;
pub mod parser;
#[cfg(test)]
mod tests;
#[derive(Debug, PartialEq)]
pub enum Format {
Raw,
RawStdin,
Matroska,
}
#[derive(Debug)]
pub struct RpuOptions {
pub mode: Option<u8>,
pub crop: bool,
}
pub f... | true |
981dee58adc7b19ef81fb30885f6924a8d437bef | Rust | llde/rObAlloc | /src/lib.rs | UTF-8 | 3,188 | 2.671875 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate kernel32;
extern crate winapi;
use std::sync::RwLock;
static doVerify : bool = true;
static ZeroInitialized : u32 = 0x00000008;
static NoSerialization : u32 = 0x00000001;
static NoFlag : u32 = 0x00000000;
static null_ptr : usize = 0x00000000;
l... | true |
f22488b7de0f53137a61162e41b6e9e5f40ca724 | Rust | DaseinPhaos/redirect | /src/resource/buffer.rs | UTF-8 | 7,612 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2017 Dasein Phaos aka. Luxko
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except a... | true |
526e43338da6f2d6499d44406b43a04d499123e7 | Rust | probe-rs/probe-rs | /probe-rs/src/architecture/arm/dp/mod.rs | UTF-8 | 26,794 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Types and functions for interacting with debug ports.
#[macro_use]
mod register_generation;
use super::{
communication_interface::RegisterParseError, ArmError, DapAccess, DapError, DpAddress, Register,
};
use bitfield::bitfield;
use jep106::JEP106Code;
use crate::DebugProbeError;
use std::fmt::Display;
/// ... | true |
a241a483cf9ad827edcd83face2a8c80407a5e14 | Rust | Lol3rrr/stream-httparse | /benches/benchmark.rs | UTF-8 | 895 | 2.609375 | 3 | [
"MIT"
] | permissive | use criterion::{criterion_group, criterion_main};
mod requests;
mod responses;
fn generate_headers<'a>(count: usize) -> stream_httparse::Headers<'a> {
let mut result = stream_httparse::Headers::new();
for i in 0..count {
let key = format!("Key-{:03}", i);
let value = format!("Value-{:03}", i);... | true |
f63283b1f6878b453ca1eed8d6b340643f6c37b7 | Rust | Friz64/smc | /src/ecs/gameplay.rs | UTF-8 | 3,046 | 2.578125 | 3 | [
"MIT"
] | permissive | use super::CurrentState;
use amethyst::{
controls::{HideCursor, WindowFocus},
core::{
nalgebra::{Unit, Vector3},
shrev::EventChannel,
specs::prelude::*,
timing::Time,
Transform,
},
input::{InputEvent, InputHandler},
renderer::Camera,
};
pub struct CameraRotat... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.