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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7670ffa77754cda1d307f755b79c4f5eeea9afce | Rust | pierreyoda/rust-lsystem | /src/bin/app.rs | UTF-8 | 2,826 | 2.6875 | 3 | [
"MIT"
] | permissive | use std::cell::RefCell;
use std::sync::mpsc::{Sender, Receiver};
use time;
use rustlsystem::*;
use rustlsystem::rules::HashMapRules;
use rustlsystem::interpret::TurtleCommand::*;
/// The application for viewing L-Systems.
pub struct Application;
impl Application {
pub fn run() {
use rustlsystem::view::M... | true |
57a603a68b535c1e205ef01ff3acb5ba470de0bb | Rust | jugglerchris/aoc2017 | /examples/day21.rs | UTF-8 | 6,868 | 3.171875 | 3 | [
"MIT"
] | permissive | #![feature(conservative_impl_trait)]
extern crate aoc2017;
use std::collections::HashMap;
#[derive(Eq,PartialEq,Debug,Copy,Clone,Hash)]
enum Square {
Empty, Full
}
use Square::*;
struct Rule {
pat: Vec<Square>,
output: Vec<Square>,
}
fn parse_rule(input: &str) -> Rule {
let parts: Vec<&str> = input.... | true |
8005d646523e73235dcab454d57d57057d88e55f | Rust | hirokazuy/rust-sample | /rust-book/tuple/src/main.rs | UTF-8 | 157 | 2.765625 | 3 | [] | no_license | struct Color(i32, i32, i32);
struct Point(i32, i32, i32);
fn main() {
let c1 = Color(1, 2, 3);
let p1 = Point(1, 2, 3);
println!("{}", c1.0);
}
| true |
a6257d00ad9e682a1635817f5c70b78def6d7ca8 | Rust | tones111/nand2tetris | /projects/06/rust/src/parser.rs | UTF-8 | 10,543 | 3.453125 | 3 | [] | no_license | #[derive(Debug)]
pub enum Instruction {
A(Address),
C(Compute),
Label(String),
}
impl std::fmt::Display for Instruction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Instruction::A(addr) => write!(f, "{}", addr),
Instruction::C(comp)... | true |
9238bfc89f2f2c3f9417e13b9f6f368943510c13 | Rust | SYAAAA/vaccel-bindings | /utilities/src/lib.rs | UTF-8 | 1,404 | 2.71875 | 3 | [] | no_license | use std::fmt;
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
extern crate vaccel;
pub enum Error {
IO(std::io::Error),
Vaccel(vaccel::Error),
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::IO(err) => wr... | true |
669dbfdf84848d481a3df75359a69257c6260e72 | Rust | Azure/azure-sdk-for-rust | /services/autorust/openapi/src/license.rs | UTF-8 | 574 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LGPL-2.1-or-later"
] | permissive | use serde::{Deserialize, Serialize};
/// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#licenseObject
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Default)]
pub struct License {
/// The name of the license type. It's encouraged to use an OSI
/// compatible license.
... | true |
32591cf6eef8a7eed5df18e509a6e5352b35b796 | Rust | alokmenghrajani/random_stuff | /cryptopals/src/utils/base64.rs | UTF-8 | 2,061 | 3.5 | 4 | [] | no_license | pub fn base64_encode(input: &[u8]) -> String {
// the result is size() * 4 / 3 rounded to next multiple of 4.
let final_size = (input.len() / 3 * 4 + 4 - 1) / 4 * 4;
let mut r = String::with_capacity(final_size);
// We populate an intermediate Vec<u8> where each u8 represents a bit.
// Not the most... | true |
eb81c7e5b8c41b9ca1879aa6f5e67d7a8b16da51 | Rust | vladmyr/rust-training | /codewars_integers_recreation_one/src/main.rs | UTF-8 | 1,867 | 3.828125 | 4 | [] | no_license | /**
* https://www.codewars.com/kata/sort-numbers/train/rust
*
* Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are:
* * 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500
* which is 50 * 50, a square!
* Given two integers m, n (1 <= m <= n) we want to find all int... | true |
ad4a4e8b684d15a7dc4f2e741f729e5bdaf4a760 | Rust | starblue/advent_of_code | /a2019/src/bin/a201919.rs | UTF-8 | 8,393 | 2.703125 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::VecDeque;
use std::io;
use std::io::Read;
use std::str::FromStr;
use nom::bytes::complete::tag;
use nom::character::complete::char;
use nom::character::complete::digit1;
use nom::combinator::map_res;
use nom::combinator::opt;
use nom::combinator::recognize;
use nom:... | true |
66172bd9998115a7254f263bd3eac4824adc4d00 | Rust | Hiddendoom45/HumbleBTATracker | /humble_btatracker_rust/src/util/trend.rs | UTF-8 | 2,199 | 2.71875 | 3 | [] | no_license | use crate::scraper::collector::HBStat;
use std::time::Duration;
fn velocity(a: HBStat, b: HBStat, scale: Duration) -> f64 {
let (o, n) = match a.timestamp > b.timestamp {
true => (b, a),
false => (a, b),
};
f64::from(n.sold - o.sold) * scale.as_secs_f64() / (n.timestamp - o.timestamp) as f... | true |
c3fc57d69b7bf7e2669a17c73d03f2bfbeb35f04 | Rust | salimclevy/csml-interpreter | /tests/string.rs | UTF-8 | 2,451 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | mod support;
use csmlinterpreter::data::{Event, MessageData};
use csmlinterpreter::interpret;
use serde_json::Value;
use support::tools::{gen_context, gen_event, message_to_jsonvalue, read_file};
fn format_message(event: Event, step: &str) -> MessageData {
let text = read_file("CSML/basic_test/stdlib/string.csml... | true |
07f3358fb5cfd693458b61a7b8019d1f2ead2027 | Rust | jiazhang0/memory-model | /src/lib.rs | UTF-8 | 6,550 | 2.984375 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file.
//! Provides a wrappe... | true |
74217cf62d379b243a326d1226a6e9fc2b8bd520 | Rust | tafia/quick-xml | /examples/read_buffered.rs | UTF-8 | 1,196 | 3.203125 | 3 | [
"MIT"
] | permissive | // This example demonstrates how a reader (for example when reading from a file)
// can be buffered. In that case, data read from the file is written to a supplied
// buffer and returned XML events borrow from that buffer.
// That way, allocations can be kept to a minimum.
fn main() -> Result<(), quick_xml::Error> {
... | true |
36d29cbf9f10655fb2417ce4bd35a5bd054bddc4 | Rust | asd153866714/learn_Rust | /04-ownership/exercise/03.rs | UTF-8 | 340 | 3.46875 | 3 | [] | no_license | fn get_word(s: &str) -> &str {
let bytes = s.as_bytes();
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
return &s[..2];
}
}
&s[..]
}
fn main() {
let my_string = String::from("test");
let my_str = "hello";
let word = get_word(my_str);
pri... | true |
b17a1c9cdf8538a51b6fd6974194661d88c2ba19 | Rust | RealOrangeOne/advent-of-code-2020 | /9-encoding-error/rust/src/main.rs | UTF-8 | 1,016 | 2.84375 | 3 | [
"MIT"
] | permissive | use itertools::Itertools;
fn main() {
let data: Vec<u64> = include_str!("../../data.txt")
.split("\n")
.filter_map(|s| s.parse::<u64>().ok())
.collect();
let invalid_code = data
.windows(26)
.map(|win| win.split_last().unwrap())
.filter(|(code, previous_values)|... | true |
b2a9e0eddbe0c458cdd977454b82a44c2491410e | Rust | Mubelotix/game | /src/actions.rs | UTF-8 | 20,737 | 2.703125 | 3 | [] | no_license | use crate::{idx::*, life::*, map::*, previsualisation::*, units::*, *};
use arr_macro::arr;
#[derive(PartialEq, Clone, Debug)]
pub enum Attack {
StickKnock,
VolleyOfArrows,
OffensiveSwordFight,
DefensiveSwordFight,
Heal,
}
impl Attack {
pub fn apply(
consequences: Vec<(HexIndex, Previs... | true |
1dc939e04995a5bfe54a4d980048c083553a4c8f | Rust | falconre/falcon | /lib/translator/options.rs | UTF-8 | 4,075 | 3.46875 | 3 | [
"Apache-2.0"
] | permissive | use crate::il;
use std::default;
/// An edge that will not be detected by Falcon's translator, but should exist.
///
/// This is used for re-lifting functions after Raptor has performed its jump
/// table analysis.
#[derive(Clone, Debug)]
pub struct ManualEdge {
head_address: u64,
tail_address: u64,
condit... | true |
4b88f5ad3b27ee495909bb0cd285466693bf9e0a | Rust | wisehead/rust_lib | /01.basic/14.file_io/arg2.rs | UTF-8 | 104 | 2.765625 | 3 | [] | no_license | fn main() {
let args = std::env::args();
for arg in args {
println!("{}", arg);
}
}
| true |
9d7af669dacd0c1373dc4d162b52030c48b07a9f | Rust | skess42/oqs-rs | /oqs/src/lib.rs | UTF-8 | 2,892 | 2.90625 | 3 | [] | no_license | #![warn(missing_docs)]
//! Friendly bindings to liboqs
//!
//! See the [`kem::Kem`] and [`sig::Sig`] structs for how to use this crate.
//!
//! # Example: Some signed KEX
//!
//! This protocol has no replay protection!
//! ```
//! use oqs::*;
//! fn main() -> Result<()> {
//! let sigalg = sig::Sig::new(sig::Algorit... | true |
8a3f171a0a89fd4db244d3439f359a98c4f2a6fd | Rust | Schenk75/Learn-Rust | /leetcode-by-rust/CCI/cci0105-一次编辑/src/main.rs | UTF-8 | 853 | 3.359375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn one_edit_away(first: String, second: String) -> bool {
if ((first.len() as i32) - (second.len() as i32)).abs() > 1 {return false;}
if first == second {return true;}
let (mut i, mut j) = (0, 0);
while i < first.len() && j < second.len() {
... | true |
426a26b33b427c0b7cd99b6d525839e5b32b69a1 | Rust | ylck/tokenizers | /bindings/node/native/src/utils.rs | UTF-8 | 1,386 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | extern crate tokenizers as tk;
use neon::prelude::*;
/// slice(s: string, start?: number, end?: number)
fn slice(mut cx: FunctionContext) -> JsResult<JsString> {
let s = cx.argument::<JsString>(0)?.value();
let len = s.chars().count();
let get_index = |x: i32| -> usize {
if x >= 0 {
x... | true |
93c0920d63a5bf63f04780a07afff16ad4c961a9 | Rust | Abbelsin/advent-of-code-2020 | /rust/day03/src/main.rs | UTF-8 | 1,244 | 3.546875 | 4 | [] | no_license | // Slope stuff
use std::fs;
fn count_trees(slope: &Vec<Vec<bool>>, dx: usize, dy: usize) -> u32 {
let mut x = 0;
let mut y = 0;
let mut n_trees = 0;
let width = slope[0].len();
let height = slope.len();
while y < height {
if slope[y][x] {
n_trees += 1;
}
x... | true |
857650c946f5670d5270d22b51dc2ead843f9e84 | Rust | EriKWDev/entity_component | /examples/simple.rs | UTF-8 | 1,040 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | use entity_component::*;
fn main() {
// Creating components
struct A(f32);
struct B(f32);
// Creating entity repository
let mut entities = Entities::default();
// Creating component storages
let mut storage = Components::<A>::default();
let mut storage2 = Components::<B>::default();
... | true |
7c46edbfecc3920baa6ef33b7536656583bf9a3b | Rust | ThomasZumsteg/exercism-rust | /grade-school/src/lib.rs | UTF-8 | 626 | 3.375 | 3 | [] | no_license | use std::collections::HashMap;
pub struct School { grades: HashMap<u32, Vec<String>>, }
impl School {
pub fn new() -> School { School { grades: HashMap::new() } }
pub fn add(&mut self, grade: u32, student: &str) {
self.grades.entry(grade).or_insert(Vec::new()).push(student.to_string());
}
pu... | true |
f8ab457be4378d13ad84523f4adba5791ee33ce6 | Rust | 751483992/rustlings | /src/exercise/variables/variables2.rs | UTF-8 | 170 | 3.3125 | 3 | [] | no_license | fn main() {
let x;
if x==10{
println!("ten");
}else{
println!("not ten");
}
}
//3 | let x;
// | ^ consider giving `x` a type | true |
bf70c162247ffc26dce2f348c2246d9170d9669e | Rust | rustwasm/gloo | /crates/dialogs/src/lib.rs | UTF-8 | 1,575 | 3.390625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! This crate provides wrapper for `alert`, `prompt` and `confirm` functions.
//! `web-sys` provides a raw API which is hard to use. This crate provides an easy-to-use,
//! idiomatic Rust API for these functions.
//!
//! See the documentation for [`alert`], [`prompt`] and [`confirm`] for more information.
use wasm_bi... | true |
a5be232f79e5d8da20a8974eb43e8ee7fa6e3c9e | Rust | minus3theta/contest | /gcj/gcj2021-1b/src/bin/c.rs | UTF-8 | 2,252 | 2.734375 | 3 | [] | no_license | // Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input_inner {
($iter:expr) => {};
($iter:expr, ) => {};
($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($iter, $t);
input_inner!{$iter $($r)*}
};
}
macro_rules! read_value {
... | true |
5b968ed44371192e1701f08e84254007b10279cb | Rust | pop-os/apt-cli-wrappers | /src/apt_lock.rs | UTF-8 | 1,028 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::{path::Path, thread, time::Duration};
const LISTS_LOCK: &str = "/var/lib/apt/lists/lock";
const DPKG_LOCK: &str = "/var/lib/dpkg/lock";
pub fn wait_for_apt_locks<R, L: FnMut(bool), F: FnOnce() -> R>(
delay: u64,
mut readiness: L,
func: F,
) -> R {
let paths = &[Path::new(DPKG_LOCK), Path::new... | true |
35f8b24731187c48e4d63ebd9b2e72133f8c2f36 | Rust | Samoxive/SafetyJim | /src/server/model/warn.rs | UTF-8 | 1,253 | 2.515625 | 3 | [
"MIT"
] | permissive | use std::num::NonZeroU64;
use serde::{Deserialize, Serialize};
use serenity::model::id::UserId;
use crate::server::model::user::UserModel;
use crate::database::warns::Warn;
use crate::service::Services;
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WarnModel {
pub id: i32,
p... | true |
e060b66b36f62c0f6d7d465356f5c057ad6bdbb4 | Rust | hooops/crypto-crawler-rs | /crypto-rest-client/src/exchanges/binance/mod.rs | UTF-8 | 1,440 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use]
mod utils;
pub(crate) mod binance_inverse;
pub(crate) mod binance_linear;
pub(crate) mod binance_option;
pub(crate) mod binance_spot;
use crate::error::Result;
use crypto_market_type::MarketType;
pub(crate) fn fetch_l2_snapshot(market_type: MarketType, symbol: &str) -> Result<String> {
let func = ma... | true |
42f30dcf81595f8c13bb737bea34092322ce65a3 | Rust | ThinkChaos/rtsp-rs | /rtsp-2/src/syntax.rs | UTF-8 | 6,502 | 2.6875 | 3 | [
"MIT"
] | permissive | use lazy_static::lazy_static;
use regex::bytes::Regex;
lazy_static! {
/// ```text
/// DQUOTE = %x22
/// UTF8-2 = <As defined in RFC 3629>
/// UTF8-3 = <As defined in RFC 3629>
/// UTF8-4 = <As defined in RFC 3629>
/// UTF8-NONASCII = UTF8-2 / UTF8-3 / UTF8-4
/// quoted-pair = "\\" / ( "\" D... | true |
ce8d6e3d7b1cc8529cb78f94c59d01cbf358b60b | Rust | amishshah/rust | /tic-tac-toe/src/main.rs | UTF-8 | 3,250 | 3.390625 | 3 | [] | no_license | use std::io;
use std::fmt;
#[derive(Clone, Copy, PartialEq)]
enum Player {
A,
B
}
impl fmt::Display for Player {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", match *self {
Player::A => "X",
Player::B => "O"
})
}
}
#[derive(Copy, Clone, PartialEq)]
enum CellType {
Empty,
Clai... | true |
07c82ff0dea5391be515b3de000c4dc0a3f18f7a | Rust | thorstel/Advent-of-Code-2019 | /day25/src/main.rs | UTF-8 | 1,053 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::collections::VecDeque;
use std::error::Error;
use std::fs;
use std::io;
use intcode::IntcodeProg;
use intcode::ProgramStatus as IPS;
fn main() -> Result<(), Box<dyn Error>> {
let mut prog = IntcodeProg::new(
&fs::read_to_string("input.txt")?
.trim()
.split(',')
... | true |
960c0494beaffc17bf99c0bc0208c98dae4a832b | Rust | nateozem/msgpack-rust | /rmpv/src/encode/value_ref.rs | UTF-8 | 2,266 | 3.265625 | 3 | [] | no_license | use std::io::Write;
use rmp::encode::{write_bool, write_nil, write_sint, write_uint, write_f32, write_f64, write_str,
write_bin, write_array_len, write_map_len, write_ext_meta};
use ValueRef;
use super::Error;
/// Encodes and attempts to write the given non-owning ValueRef into the Write.
///
/// #... | true |
5e52375b534b353c6389ef14937434d9f3c0c2ef | Rust | frehberg/async-hsm | /src/lib.rs | UTF-8 | 10,826 | 3.359375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! The asynchronous hierarchical state machine (HSM)
//!
//! This state machine is an programmatic approach. It uses features of async-await
//! functionality, and combines it with usage of the process stack and scoping.
//!
//! Instead of storing state as variable, the state is represented by an async function.
//! ... | true |
c06027b725e12b2c9df37c40934bb0a90ddcba79 | Rust | indeterminateoutcomesstudios/gemini | /src/gui/dialog/multi.rs | UTF-8 | 2,754 | 2.984375 | 3 | [
"MIT"
] | permissive | use super::*;
use tui::{
layout::{Direction, Group, Rect, Size},
style::{Color, Style},
widgets::{Block, Borders, SelectableList, Widget},
};
type Action = Fn(&mut Sender<Event>) -> Option<GUIEvent>;
/// Multiple choice dialog window.
pub struct MultiDialog {
sender: Sender<Event>,
title: String,
... | true |
1351459bd35f9d3efe409646fd08c92bc98bea9e | Rust | WhoSoup/aoc2020 | /day18/src/main.rs | UTF-8 | 2,109 | 3.703125 | 4 | [
"MIT"
] | permissive | use lazy_static::lazy_static;
use regex::Regex;
#[derive(Debug)]
enum Op {
Number(u64),
Plus,
Mul,
}
lazy_static! {
static ref PARENTHESES: Regex = Regex::new(r"\(([^\(\)]+)\)").unwrap();
}
fn convert(s: &str) -> Op {
match s {
"*" => Op::Mul,
"+" => Op::Plus,
_ => Op::Numb... | true |
15feb9f4c0a2674dcf0806113520f24323404134 | Rust | dbyr/rb_tree | /src/rbqueue.rs | UTF-8 | 15,337 | 3.21875 | 3 | [
"MIT"
] | permissive | use crate::RBQueue;
#[cfg(feature = "set")]
use crate::RBTree;
use crate::helpers::{ordered_insertion, write_to_level};
use crate::node::Colour::Black;
use crate::node::Node::Leaf;
use std::fmt::{Debug, Display, Formatter, Result};
use std::iter::{ExactSizeIterator, FusedIterator};
impl<T: Debug, P> Debug for RBQueue... | true |
7278e9524d42a5e43020826975f2c5b752d8b6b8 | Rust | seanlth/TUIrs | /src/window.rs | UTF-8 | 896 | 3.109375 | 3 | [] | no_license | use view::*;
use geometry::*;
use tile::*;
pub struct Window {
pub rect: Rect,
pub view: View,
}
impl Window {
pub fn new(rect: Rect) -> Window {
Window {
rect: rect,
view: View::new_default("main".to_string(), rect, Point::new(0, 0)),
}
}
pub fn redraw(&mut self) {
self.view.draw();
print!("\x1... | true |
8adc84e8b48d2f27d6892bc3d20117ba189f73b5 | Rust | arun11299/Rust-Practice | /iter_test.rs | UTF-8 | 85 | 2.828125 | 3 | [] | no_license |
fn main() {
let v = vec![1, 2, 3];
assert_eq!(v.iter().next(), Some(&1));
}
| true |
15622acf94132ff2d639a3da89021ee7f04345f7 | Rust | razielgn/ostrov | /tests/eval_conditionals.rs | UTF-8 | 509 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::helpers::{values::*, *};
use ostrov::errors::RuntimeError::*;
#[test]
fn if_with_one_arg() {
assert_eval("(if #t 3)", "3");
assert_eval_val("(if #f 3)", unspecified());
}
#[test]
fn if_with_two_args() {
assert_eval("(if #t (+ 1) a)", "1");
assert_eval("(if #f a (+ 1))", "1");
assert_eva... | true |
82c15aab5bd90ea089ae124f149ee61991eae30f | Rust | valdron/aoc-2017 | /src/day3/mod.rs | UTF-8 | 3,020 | 3.171875 | 3 | [] | no_license | pub fn run(input: &str) -> Result<u64, String> {
let x: u64 = input.trim().parse().map_err(|e| format!("{:?}", e))?;
let mut circle = SpiralMem::new();
let (x, y) = circle.nth((x - 2) as usize).ok_or("IterError!".to_owned())?;
let res = x.abs() + y.abs();
Ok(res as u64)
}
pub fn run2(input: &str) ... | true |
e37f692da21dda12c517d00723f91f2d99b1284c | Rust | baitcenter/cvmath | /src/num/abs.rs | UTF-8 | 442 | 2.890625 | 3 | [] | no_license |
pub trait Abs {
type Output;
fn abs(self) -> Self::Output;
}
//----------------------------------------------------------------
// Implementation
macro_rules! impl_abs {
($ty:ty) => {
impl Abs for $ty {
type Output = $ty;
fn abs(self) -> $ty {
self.abs()
}
}
}
}
/*
impl_abs!(u8);
impl_abs!(u16);
impl_abs!... | true |
e15cf339ecd5d8e63772ff5ed7a3e61e6ba3550a | Rust | do4gr/congenial-barnacle | /tests/generate_test_file.rs | UTF-8 | 1,941 | 2.75 | 3 | [] | no_license | use rand::distributions::WeightedIndex;
use rand::prelude::*;
use rand::seq::SliceRandom;
use rand::Rng;
use rust_decimal::Decimal;
use std::collections::HashMap;
#[ignore]
#[test]
/// quick and dirty sample file generator, will produce invalid transactions
fn generate_test_file() -> Result<(), Box<dyn std::error::Err... | true |
261e08b8dc7a35efd5299ac7684af32ede00970e | Rust | etwyniel/8bit_computer | /src/shareable.rs | UTF-8 | 800 | 3.03125 | 3 | [] | no_license | use std::cell::Cell;
use std::rc::Rc;
pub trait Share<T: Copy> {
fn share(&self) -> Shared<T>;
}
#[derive(Debug, Default)]
pub struct Shareable<T: Copy>(Rc<Cell<T>>);
#[derive(Debug)]
pub struct Shared<T: Copy>(Rc<Cell<T>>);
impl<T: Copy> Shareable<T> {
pub fn new(init: T) -> Self {
Shareable(Rc::ne... | true |
0651ef1586cd52ac9a53ddf50d201ac5b4a8f15e | Rust | Cassin01/neku | /src/lib2/poly.rs | UTF-8 | 1,145 | 2.96875 | 3 | [] | no_license | extern crate rand;
struct Polynomial {
coefficients: Vec<u8>,
n: u32,
}
impl Polynomial {
fn new(k: u32, n: u32, seacret: u8) -> Self {
use rand::Rng;
let mut rng = rand::thread_rng();
Self {
coefficients: (0..n).map(|p| rng.gen::<u8>() % 2).collect(),
n,
... | true |
63fb8315ab26cff63723b9866f1be93398062670 | Rust | einbergisak/Fog-of-War-Chess | /src/render_utilities.rs | UTF-8 | 12,933 | 2.703125 | 3 | [] | no_license | use ggez::{
graphics::{self, spritebatch::SpriteBatch, DrawMode, DrawParam, Image, MeshBuilder, Rect},
nalgebra::{Point2, Vector2},
Context, GameResult,
};
use crate::{
event_handler::{BOARD_ORIGO_X, BOARD_ORIGO_Y, BOARD_SIZE, TILE_SIZE},
game::Game,
piece::piece::{get_piece_rect, get_valid_mov... | true |
54509347dcc0862bcf7a870e76fcd9f9583b60d5 | Rust | ylambda/advent-of-code-2019 | /day22/src/main.rs | UTF-8 | 3,808 | 3.609375 | 4 | [] | no_license | use std::collections::HashMap;
use std::ops::{Add, Sub};
use std::iter::FromIterator;
fn main() {
let input = include_str!("./input.txt");
let maze = Maze::from_input(input);
maze.render();
}
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
struct Coord {
x: isize,
y: isize
}
impl Coord {
... | true |
21e516a7c9ec7c831a7372308c5f44278a4e4b62 | Rust | angular-rust/opengles-tutorial | /c01_getting_started/src/bin/c01_061_coordinate_systems.rs | UTF-8 | 8,588 | 2.546875 | 3 | [
"MIT"
] | permissive | use c01_getting_started::Shader;
use cgmath::{perspective, vec3, Deg, Matrix4};
use dx::{
assets,
gles::{core30::gl, enums::*},
Instance,
};
use image::GenericImageView;
use std::mem;
use winit::{
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
event_loop::{ControlFlow, Eve... | true |
ac8b91a2148c8514e7602da99c821ef4a5199438 | Rust | JackAllTrades-MoN/x86emu | /src/emulator/pc9801vm/display.rs | UTF-8 | 3,499 | 2.515625 | 3 | [] | no_license | use glium::Surface;
use glium::glutin;
use std::sync::{Arc, Mutex};
use super::super::pc9801vm::Machine;
use super::crt::Crt;
use super::ram::GVRam;
#[derive(Copy, Clone)]
struct Vertex {
pub position: [f32; 2],
pub color: [f32; 3],
}
glium::implement_vertex!(Vertex, position, color);
const vertex_shader_sr... | true |
66e8d934c3976e25619d0a5fcd55bba56fd4d7fb | Rust | YoCodingJosh/rust-playground | /ch01/src/main.rs | UTF-8 | 2,571 | 4.15625 | 4 | [
"CC0-1.0"
] | permissive | fn main() {
println!("Let's play around a bit with logic and repetition.");
// let declares a variable as immutable.
let x:i8 = 10;
// but if you declare it as let mut, it's just a normal variable declaration
let mut y:i8 = 13;
// println is kinda like printf but is a bit better because y... | true |
cf77cc5196f65c3b9e702dde7804f10a2f146617 | Rust | arthmis/druid-gridview | /src/lib.rs | UTF-8 | 15,691 | 3.359375 | 3 | [] | no_license | //! A basic grid view widget.
use std::{cmp::Ordering, sync::Arc};
use druid::im::Vector;
use druid::{
widget::Axis, BoxConstraints, Data, Env, KeyOrValue, LifeCycle, Point,
Rect, Size, Widget, WidgetPod,
};
/// A grid view widget for a variable size collection of items.
pub struct GridView<T> {
closure... | true |
6d1a12efecf67d9901fc9d0e04466ce034f025c3 | Rust | arkworks-rs/algebra | /ff/src/fields/models/quadratic_extension.rs | UTF-8 | 26,953 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use ark_serialize::{
CanonicalDeserialize, CanonicalDeserializeWithFlags, CanonicalSerialize,
CanonicalSerializeWithFlags, Compress, EmptyFlags, Flags, SerializationError, Valid, Validate,
};
use ark_std::{
cmp::{Ord, Ordering, PartialOrd},
fmt,
io::{Read, Write},
iter::Chain,
ops::{Add, Add... | true |
2a3f3ebddd5f99b4f3e28fd217e6db0df5c86ba6 | Rust | veltzer/demos-rust | /src/io/write_file_basic.rs | UTF-8 | 401 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | // This is a basic example of how to write fomatted data to a file in Rust
// Rust will take care of closing the file
//
// References:
// - https://stackoverflow.com/questions/32472495/how-do-i-write-a-formatted-string-to-a-file
use std::fs::File;
use std::io::Write;
fn main() {
let mut w = File::create("/tmp/te... | true |
256a710c32fee3594691ab5fc80d7b381b3c381b | Rust | blue68/bitflyer-rs | /src/api/get_deposits.rs | UTF-8 | 1,109 | 2.828125 | 3 | [] | no_license | use crate::api;
use crate::api::{ApiResponseError, ProductCode, BEFORE_QUERY_KEY, AFTER_QUERY_KEY, COUNT_QUERY_KEY, CurrencyCode, OrderStatusType};
use std::collections::HashMap;
const PATH : &'static str = "/v1/me/getdeposits";
type GetDepositsResponse = Vec<DepositInfo>;
#[derive(Deserialize, Debug)]
pub struct De... | true |
6a2183033ac940f4d83093af1b7fa2b499fb1d6f | Rust | henrikpersson/potatis | /nes/src/frame.rs | UTF-8 | 2,734 | 3.15625 | 3 | [
"MIT"
] | permissive | use alloc::vec::Vec;
type SetPixelFn = fn(&mut [u8], i: usize, rgb: (u8, u8, u8));
pub trait SetPixel {
fn set_pixel(buf: &mut [u8], i: usize, rgb: (u8, u8, u8));
}
pub trait PixelFormat {
const BYTES_PER_PIXEL: usize;
}
pub struct PixelFormatRGB888;
impl PixelFormat for PixelFormatRGB888 {
const BYTES_PER_P... | true |
eebc7f3ff4055829a44f0b57b25c2125e7c2c002 | Rust | rainliu/rsplit | /src/psnr.rs | UTF-8 | 6,354 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io;
use std::io::Read;
use std::io::{Error, ErrorKind};
pub struct Psnr {
pub input1_yuv: String,
pub input2_yuv: String,
pub frame_num: usize,
pub frame_size: Vec<(i32, i32)>,
}
impl Psnr {
pub fn helper() {
println!("Usage: rsplit psnr input1.yuv input2.yuv fr... | true |
ac14c8456b0896073c44bea24287383c72eff0e2 | Rust | j-browne/advent-of-code | /2016/src/keypad.rs | UTF-8 | 2,697 | 3.703125 | 4 | [] | no_license | pub enum Direction {
U,
R,
D,
L,
}
impl From<char> for Direction {
fn from(c: char) -> Direction {
match c {
'U' => Direction::U,
'R' => Direction::R,
'D' => Direction::D,
'L' => Direction::L,
_ => {
panic!();
... | true |
6b97d67844544dd57c002d7429e586eac88c460d | Rust | Stebalien/rust-multihash | /src/lib.rs | UTF-8 | 3,999 | 2.78125 | 3 | [
"MIT"
] | permissive | //! Multihash implementation.
//!
//! Feature Flags
//! -------------
//!
//! Multihash has lots of [feature flags], by default a table with cryptographically secure hashers
//! is created.
//!
//! Some of the features are about specific hash functions, these are ("default" marks the hashers
//! that are enabled by def... | true |
9361ccc2614891c6a0e5fd68b279eb738c5e1b7e | Rust | rust-lang/cargo-bisect-rustc | /src/git.rs | UTF-8 | 6,742 | 2.703125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Get git commits with help of the libgit2 library
const RUST_SRC_URL: &str = "https://github.com/rust-lang/rust";
const RUST_SRC_REPO: Option<&str> = option_env!("RUST_SRC_REPO");
use std::env;
use std::ops::Deref;
use std::path::Path;
use anyhow::{bail, Context};
use chrono::{TimeZone, Utc};
use git2::build::Rep... | true |
5a64cf29d890de28883ec1e33029997e257f1852 | Rust | Yoric/games-for-redox | /src/rusthello/interface.rs | UTF-8 | 15,262 | 3.1875 | 3 | [] | no_license | //! This module provides interface functionalities and manages all the input/output part of the program
use std::string::String;
use std::io::{self, Write};
use reversi::Side;
use reversi::board::{BOARD_SIZE, Coord};
use reversi::game::PlayerAction;
use reversi::turn::{State, Turn};
use ::{Result, Action, OtherAction}... | true |
8eea38a1633928461e5f3fb60d294994883e3c1c | Rust | Samour/jobmatching-rust | /src/collections/capped_heap.rs | UTF-8 | 2,675 | 3.46875 | 3 | [] | no_license | #[derive(Debug)]
struct HeapNode<T> {
value: f64,
item: T,
}
#[derive(Debug)]
pub struct CappedHeap<T> {
size: usize,
push_head: usize,
data: Vec<Option<HeapNode<T>>>,
}
impl<T> CappedHeap<T> {
pub fn new(size: usize) -> CappedHeap<T> {
let mut data = Vec::with_capacity(size + 1);
for _ in 0..size... | true |
baf5207047529ddfe98af9b37f5729a75fe3e6a1 | Rust | luaks/vlq-parser | /src/vlq_parser.rs | UTF-8 | 3,252 | 3.140625 | 3 | [] | no_license | const MAX_VLQ_STRING_LENGTH_FOR_60_BITS: usize = 12;
const MAX_VLQ_STRING_LENGTH_FOR_64_BITS: usize = 13;
const SHIFT_FACTOR: u8 = 5;
const VLQ_LAST_CHAR_MASK: u8 = 0b00100000;
const VLQ_CHAR_VALUE_MASK: u8 = 0b00011111;
#[derive(Debug,PartialEq)]
pub enum VlqParserError {
VlqInvalidStringLength = 0,
VlqInvali... | true |
0ac669a10a6bb49e67e0c491bfa20c680aeb93ec | Rust | PIAIC-IOT/Batch3_Q2 | /2020_05_31/closure/src/main.rs | UTF-8 | 853 | 3.328125 | 3 | [] | no_license | fn welcome(){
println!("Welcome after EID");
}
fn myfunction(data:u8){
println!("We got data : {}",data);
}
fn main() {
welcome();
println!("Hello, world!");
let age:u8 = 55;
myfunction(age);
let myclosure = ||{
println!("Welcome in my closure");
};
myclosure();
let iot... | true |
e7e142ef1d2d87d87684f2b0c9d152b4233270db | Rust | h2obrain/stm32f4xx-hal | /src/serial/hal_1.rs | UTF-8 | 3,786 | 3.078125 | 3 | [
"0BSD",
"BSD-3-Clause"
] | permissive | use embedded_hal_one::serial::ErrorType;
impl<USART, PINS, WORD> ErrorType for super::Serial<USART, PINS, WORD> {
type Error = super::Error;
}
impl<USART, WORD> ErrorType for super::Rx<USART, WORD> {
type Error = super::Error;
}
impl<USART, WORD> ErrorType for super::Tx<USART, WORD> {
type Error = super:... | true |
1b157ef964d84483d49d0953091598fb548279d6 | Rust | czak/doodle | /tools/src/bin/estimate.rs | UTF-8 | 1,341 | 2.828125 | 3 | [] | no_license | use chrono::prelude::*;
use scraper::{Html, Selector};
// 12 weeks
const PATTERN_LEN: i64 = 84;
const PATTERN: [i64; 12] = [0, 8, 16, 24, 32, 40, 48, 54, 60, 66, 72, 78];
const TARGET_LOW: u32 = 4;
const TARGET_HIGH: u32 = 10;
fn main() {
let username = std::env::args().nth(1).expect("must specify username");
... | true |
842af96c94de5f0c43e8dfe15a6ecbdbbf5519ce | Rust | Snivellus/libra | /language/tools/mirai-dataflow-analysis/src/configuration.rs | UTF-8 | 5,476 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use std::{
fs,
path::{Path, PathBuf},
};
use serde::{Deserialize, Serialize};
use crate::{datalog::DatalogBackend, util::make_absolute};
/// Specifies reduction operations that may be performed
/// on a call graph. Supported ... | true |
082e86877c0babc5e87a031afd7788b95b1be591 | Rust | rhlahuja/advent-of-code-2020 | /day-08/rust/src/main.rs | UTF-8 | 2,880 | 3.375 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs;
use std::path::Path;
use itertools::Itertools;
#[derive(Default)]
struct Program {
instructions: Vec<String>,
executed_instruction_indices: HashSet<usize>,
accumulator: i32,
}
impl Program {
fn run(&mut self, mut index: usize) -> (bool, &i32) {
for ... | true |
db39c00e9a310536efd5dd343a5099c4aa774765 | Rust | davidszotten/advent-of-code-2017 | /src/day17.rs | UTF-8 | 957 | 2.96875 | 3 | [] | no_license | use shared::AppResult;
pub fn part1(input: &str) -> AppResult<u32> {
let inc: usize = input.parse().expect("parsing failed");
let mut buf = vec![0];
let mut length = 1;
let mut pos = 0;
for step in 1..2018 {
// for step in 1..10 {
pos = (pos + inc) % length;
buf.insert(pos + 1, ... | true |
7df86bfc4e010976d29a626e99bf26b71a06776e | Rust | dogesoulseller/csrs | /src/processing/track_process.rs | UTF-8 | 1,956 | 2.84375 | 3 | [
"MIT"
] | permissive | use super::defs::*;
use super::util::*;
pub fn get_track_index(lines : &Vec<String>) -> usize {
for l in lines {
if l.contains("TRACK") {
let mut split = l.trim_end().trim_start().split_whitespace();
return split.nth(1).or_else(|| panic!("Track line had no index value")).unwrap().parse::<usize>().unwrap();
... | true |
2023d1093ce55a118d53a781c031f3af3c9403d2 | Rust | eriol/smbios-uuid | /src/main.rs | UTF-8 | 2,604 | 3.046875 | 3 | [
"MIT"
] | permissive | // Copyright © 2019 Daniele Tricoli <eriol@mornie.org>
// smbios-uuid is licensed under the MIT License, see LICENSE.
use std::process;
use clap::{crate_authors, crate_version, App, Arg};
use colored::Colorize;
use uuid::Uuid;
const ABOUT: &str = "
smbios-uuid is an utility to convert an UUID defined as in RFC4122
i... | true |
756cce4186be51251b2cc2b2bf73bbaf29ac4d11 | Rust | jpverkamp/advent-of-code | /2022/src/bin/05-stackinator.rs | UTF-8 | 4,429 | 3.5 | 4 | [] | no_license | use aoc::*;
use std::{collections::LinkedList, path::Path};
#[derive(Debug)]
struct Stack {
data: Vec<char>,
}
#[derive(Debug)]
struct Warehouse {
stacks: Vec<Stack>,
}
impl Warehouse {
fn from(lines: &Vec<String>) -> Warehouse {
let mut data = Vec::new();
for line in lines {
... | true |
494277e75cf34397e606dbbeac4749fb5928bba2 | Rust | gtolle/rest_client | /examples/client.rs | UTF-8 | 1,987 | 2.75 | 3 | [
"MIT"
] | permissive | extern crate rest_client;
extern crate rustc_serialize;
use rest_client::RestClient;
use rustc_serialize::json;
use rustc_serialize::json::Json;
#[derive(RustcDecodable, RustcEncodable)]
pub struct TestStruct {
data_int: u8,
data_str: String,
data_vector: Vec<u8>,
}
fn main() {
println!("{}", RestCl... | true |
4ae5a74bdbbe8ae5f76aec10c97740728b269f92 | Rust | johanlindblad/advent-of-code-2018 | /src/day20.rs | UTF-8 | 4,282 | 3.328125 | 3 | [] | no_license | use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::collections::BTreeMap;
fn calculate_distances(input: &str) -> BTreeMap<(isize, isize), usize> {
let trimmed = &input[1..input.len()];
let mut neighbours: BTreeMap<(isize, isize), Vec<(isize, isize)>> = BTreeMap::new();
let mut chars ... | true |
0a2ef12536499aaa9bb35c86fdb1c4a255befdf8 | Rust | Anurag-Dutta/Rust-Codes | /Even_Range.rs | UTF-8 | 143 | 3.015625 | 3 | [] | no_license | fn main()
{
let mut range = 10;
for i in 1..range+1
{
if i%2==0
{
println!("{}", i);
}
}
} | true |
7f05c8af9d88b6081a46fb95614f6712bff99009 | Rust | sergeysova/rust-learning | /07/src/demo/mod.rs | UTF-8 | 388 | 3 | 3 | [] | no_license | pub mod tra;
use self::tra::Tra;
pub struct Type {
a: i32,
b: String,
}
impl Type {
pub fn new(a: i32, b: &str) -> Type {
Type {
a: a,
b: b.to_string(),
}
}
pub fn concat(&self) -> String {
"".to_string() + &self.b + &self.a.to_string()
}
}
im... | true |
05cfa077e72d14fc2133115db70cd5a2ee497cc1 | Rust | kirikaza/postgread | /src/msg/body/query.rs | UTF-8 | 888 | 2.859375 | 3 | [] | no_license | use crate::msg::type_byte::TypeByte;
use crate::msg::util::decode::*;
use ::std::fmt::{self, Debug, Formatter};
#[derive(Clone, PartialEq)]
pub struct Query (
pub Vec<u8>
);
impl Query {
pub const TYPE_BYTE: u8 = b'Q';
}
impl MsgDecode for Query {
const TYPE_BYTE_OPT: Option<TypeByte> = Some(TypeByte::Qu... | true |
1198be79918d1112f0947df41942c6d6d6f6b664 | Rust | bombsimon/slack-giphy | /src/main.rs | UTF-8 | 3,509 | 3.265625 | 3 | [
"MIT"
] | permissive | use slack::api::MessageStandard;
use slack::{Event, EventHandler, Message, RtmClient};
struct GiphyBot {
/// GiphyBot is the bot that sends gifs to Slack based on configured keywords.
giphy_api_key: String,
giphy_keywords: Vec<String>,
}
#[allow(unused_variables)]
impl EventHandler for GiphyBot {
/// ... | true |
68094f10040a814e5f7ff3deb9b8b23e433b946d | Rust | eugenezastrogin/squooshNode | /codecs/png/src/lib.rs | UTF-8 | 1,851 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::io::Cursor;
use wasm_bindgen::prelude::*;
use wasm_bindgen::Clamped;
// Custom ImageData bindings to allow construction with
// a JS-owned copy of the data.
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(typescript_type = ImageData)]
pub type ImageData;
#[wasm_bindgen(constructor)]
fn new_with_... | true |
8a4de674c8301990084495dc7a165b73b1a2a0e4 | Rust | manishmeganathan/tokenizer | /src/token.rs | UTF-8 | 901 | 3.609375 | 4 | [
"MIT"
] | permissive | // This module contains the token definitions for the lexer
#[derive(PartialEq)]
#[derive(Debug)]
pub enum TokenType {
ILLEGAL,
EOF,
IDENT,
INT,
STRING,
PLUS,
MINUS,
BANG,
ASTERISK,
SLASH,
TILDE,
PIPE,
ASSIGN,
LT,
GT,
EQ,
NEQ,
COMMA,
COLO... | true |
1f58150d033084f6267dd25f7ba27033d328b235 | Rust | ethanluoyc/boxtica | /src/push_box/Block.rs | UTF-8 | 458 | 3.46875 | 3 | [] | no_license | pub enum Block {
Empty,
Player,
Wall,
Boxtica,
// Whether target has a box or not
Target(bool),
}
impl Block {
pub fn can_place_item(&self) -> bool {
match *self {
Block::Empty | Block::Target(false) => true,
_ => false,
}
}
pub fn can_move(&... | true |
2660881addabc012aa5db52ec53e24f82e3e4adc | Rust | eduardobraun/guesser | /src/main.rs | UTF-8 | 3,764 | 3.1875 | 3 | [] | no_license | use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::error::Error;
use std::fmt;
use rand::thread_rng;
use rand::Rng;
use wasmer::{Instance, Module, Store, Function, FunctionType, Type, Value, imports};
use wasmer_compiler_cranelift::Cranelift;
use wasmer_engine_jit::JIT;
#[derive(Debug)]
struct... | true |
82b7e74a5721afd0e9ae1009e781b3d0af149c14 | Rust | joeftiger/rust-v | /geometry/src/lib.rs | UTF-8 | 18,404 | 2.953125 | 3 | [
"MIT"
] | permissive | mod aabb;
mod bubble;
pub mod bvh;
mod composite;
mod cylinder;
mod debug_util;
mod disk;
mod lenses;
mod mesh;
pub mod obj_file;
mod plane;
mod point;
mod ray;
mod sphere;
#[cfg(not(feature = "f64"))]
pub type Float = f32;
#[cfg(not(feature = "f64"))]
pub type Vector3 = ultraviolet::Vec3;
#[cfg(not(feature = "f64"))]... | true |
b6a15fe44ea65adc82565175fe0cdccc268e2899 | Rust | onnovalkering/brane | /brane-oas/tests/build_input.rs | UTF-8 | 3,778 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | mod common;
use anyhow::Result;
#[test]
fn param_count_matches_function_param_count() -> Result<()> {
let (function, _) = common::build_oas_function_param("/param-count/{1}", "onlyPathParameters")?;
assert_eq!(function.parameters.len(), 1);
let (function, _) = common::build_oas_function_param("/param-cou... | true |
3c74622de95da518bb5f571398bf39428e084fbb | Rust | bieganski/distributed | /dsassignment02/public-tests/tests/client_msg_serial.rs | UTF-8 | 2,364 | 2.5625 | 3 | [] | no_license | use assignment_2_solution::{
deserialize_register_command, serialize_register_command, ClientCommandHeader,
ClientRegisterCommand, ClientRegisterCommandContent, RegisterCommand, SectorVec
};
use ntest::timeout;
use std::io::BufWriter;
use std::io::BufReader;
use std::io::Read;
use std::fs::File;
use std::io::Cu... | true |
c2746a788862968ebd458983e895a9b2185025a3 | Rust | xiroV/Cuckoo | /src/ui/repl/exit_controller.rs | UTF-8 | 921 | 2.625 | 3 | [
"MIT"
] | permissive | use ui::repl::{ReplUI, Command, CommandHandler};
use cuckoo::ServiceBundle;
use std::io::{Read, Write};
use super::utils;
use super::menu;
pub struct ExitController;
impl<I: Read, O: Write> CommandHandler<I, O> for ExitController {
fn handle(&self, ui: &mut ReplUI<I, O>, _bundle: &mut ServiceBundle,
... | true |
a28c77ed533884e91f6eb44c66b584fed29dd4bd | Rust | afaber999/dicom-pipe | /dcmpipe_cli/src/app/editapp.rs | UTF-8 | 6,221 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::Ordering;
use std::fs::File;
use std::path::{Path, PathBuf};
use anyhow::Result;
use cursive::traits::{Boxable, Identifiable};
use cursive::views::{Dialog, TextView};
use cursive::Cursive;
use cursive_table_view::{TableView, TableViewItem};
use dcmpipe_dict::dict::stdlookup::STANDARD_DICOM_DICTIONARY;
u... | true |
70b4d5ea9f2e02361745a994b5f5f92197d4c3d6 | Rust | xorphitus/gpm-renamer | /src/main.rs | UTF-8 | 1,070 | 2.890625 | 3 | [] | no_license | use id3::Tag;
use regex::{Regex, NoExpand};
use std::fs;
use std::path::Path;
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} have to specify a mp3 file name", &args[0]);
return;
}
let file_path_str = &args[1];
let file_path ... | true |
677e31b48e7f2c34e200eb36700ddce82716cf6b | Rust | wez/max32630 | /max32630_svd/src/pwrseq/reg6/mod.rs | UTF-8 | 11,322 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | 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::REG6 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
4314eb6529054ee89833ef0665d11c60dafe7068 | Rust | PoorlyDefinedBehaviour/data-structures-and-algorithms | /rust/algorithms/others/contains_duplicate/main.rs | UTF-8 | 1,185 | 4.15625 | 4 | [
"MIT"
] | permissive | //! 217. Contains Duplicate
//!
//! Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
//!
//! Example 1:
//!
//! Input: nums = [1,2,3,1]
//! Output: true
//!
//! Example 2:
//!
//! Input: nums = [1,2,3,4]
//! Output: false
//!
//! E... | true |
62f69e7e712c0bf2864a50f30249f888c9155c42 | Rust | utilForever/BOJ | /Rust/27926 - Quartet.rs | UTF-8 | 2,176 | 2.953125 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_iter: ""... | true |
0733ac6ce21658ec1449efa864721fed9f72d5ed | Rust | antlilja/raytracer | /cpu-raytracer/src/main.rs | UTF-8 | 7,964 | 2.734375 | 3 | [] | no_license | mod camera;
mod material;
mod math;
mod plane;
mod random;
mod ray;
mod sphere;
mod vec3;
use camera::Camera;
use material::Material;
use math::clamp01;
use plane::Plane;
use random::RngXorShift;
use ray::Ray;
use sphere::Sphere;
use vec3::Vec3;
use std::fs::File;
const SAMPLES: usize = 256;
const SAMPLE_SCALE: f32 ... | true |
9ab26aca514ef0499225f469aa6544dc24ea5d16 | Rust | storyfeet/any_cards | /src/main.rs | UTF-8 | 5,798 | 2.53125 | 3 | [] | no_license | mod go_temp;
use clap_conf::prelude::*;
use std::collections::BTreeMap;
use thiserror::*;
use gobble::Parser;
use gtmpl::Template;
use gtmpl_helpers::THelper;
use std::io::Read;
//use std::str::FromStr;
#[derive(Error, Debug)]
#[error("{}{}", s, e)]
pub struct QErr<E: std::error::Error> {
e: E,
s: String,
}
... | true |
3afe3036065a3d11668e8774a7791dada90abe65 | Rust | IThawk/rust-project | /rust-master/src/test/ui/parser/issue-3036.rs | UTF-8 | 162 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Testing that semicolon tokens are printed correctly in errors
fn main()
{
let x = 3
} //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}`
| true |
edd8f6332841af67250b70203536c29dc68fda8c | Rust | DrunkFlamingo/kailua | /kailua_types/src/ty/literals.rs | UTF-8 | 9,480 | 3.125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
use std::collections::BTreeSet;
use kailua_syntax::Str;
use diag::{Origin, TypeResult};
use super::{Display, DisplayState, TypeContext, Lattice, Union};
/// Number types.
#[derive(Clone)]
pub enum Numbers {
/// A single integer literal.
One(i32),
/// Multiple integer literals.
Some(BTre... | true |
0fa9d6792cce8f19cef8e011ddc1a85697703e63 | Rust | buxx/rollgui | /src/ui/renderer/state_less_button.rs | UTF-8 | 3,623 | 2.890625 | 3 | [
"MIT"
] | permissive | use crate::ui::renderer::Renderer;
use crate::ui::widget::state_less_button;
use coffee::graphics::{
Color, HorizontalAlignment, Point, Rectangle, Sprite, Text, VerticalAlignment,
};
use coffee::ui::core::MouseCursor;
const LEFT: Rectangle<u16> = Rectangle {
x: 0,
y: 1034,
width: 6,
height: 49,
};
... | true |
06932f1679fba1e7366185a9d1fe7901c17e3488 | Rust | willfindlay/aoc2020 | /will/day10/src/main.rs | UTF-8 | 1,768 | 3.46875 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use std::collections::HashMap;
use std::io::{stdin, Read};
fn main() -> Result<()> {
let mut input = String::new();
stdin().read_to_string(&mut input)?;
let parsed = parse_input(&input)?;
part1(&parsed)?;
part2(&parsed)?;
Ok(())
}
/// Solve part 1
fn part1(input: &Vec<u6... | true |
6f363fa5a7ac0274cc106839b4619351924aa47f | Rust | mbebenita/wasmparser.rs | /src/tests.rs | UTF-8 | 1,638 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | /* Copyright 2017 Mozilla Foundation
*
* 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 agreed... | true |
cbd3b926511cdfd6e4afc82978fb454d1c8ceb90 | Rust | pmcjones/elements_in_rust | /src/lib.rs | UTF-8 | 28,160 | 3.671875 | 4 | [] | no_license | pub mod elements {
extern crate num;
use std::ops::{Shr};
use self::num::{Zero, One, NumCast};
//-----------------------------------------------------------------------------
// 1.5 Regular Types
// Regular types enable normal value semantics, except we require explicit
// cloning rather... | true |
d1db362ee1bfa31cfa19e782677fe7350f1c17c9 | Rust | HerringtonDarkholme/leetcode | /src/459_repeated_substring_pattern.rs | UTF-8 | 429 | 2.875 | 3 | [] | no_license | impl Solution {
pub fn repeated_substring_pattern(s: String) -> bool {
let s = s.as_bytes();
(1..=(s.len() / 2))
.filter(|len| s.len() % len == 0)
.any(|len| can_divide(s, len))
}
}
#[inline(always)]
fn can_divide(s: &[u8], len: usize) -> bool {
for i in 1..(s.len() /... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.