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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
69990c5f2b197a461f995ddf47a079eb43ef02aa | Rust | matthewfritsch/TCS-Projects | /Projects/04-Rock_Paper_Scissors/Rust/main.rs | UTF-8 | 1,704 | 3.25 | 3 | [] | no_license | use std::io;
use std::io::Write;
use rand::Rng;
fn user_input_str() -> String {
let mut buff = String::new();
let _rl_result = io::stdin().read_line(&mut buff);
buff.trim().to_string()
}
fn user_input_i32() -> i32 {
let mut buff = String::new();
let _rl_result = io::stdin().read_line(&mut buff);
... | true |
beee1f74aa32b5303c930fc81c98bfacfb0ecbbe | Rust | SrimantaBarua/bed_low_level | /rype/src/loca.rs | UTF-8 | 1,410 | 2.6875 | 3 | [
"MIT"
] | permissive | // (C) 2020 Srimanta Barua <srimanta.barua1@gmail.com>
use crate::error::*;
use crate::head::IdxLocFmt;
use crate::types::{get_u16, get_u32};
#[derive(Debug)]
pub(crate) struct Loca(Vec<u32>);
impl Loca {
pub(crate) fn load(data: &[u8], num_glyphs: usize, idx_loc_fmt: IdxLocFmt) -> Result<Loca> {
let mut... | true |
89268764f0dcf4ec7576f1a2e6ea4a7c4dfedb94 | Rust | jadestrong/pandadoodle-rust-wasm | /src/engine/audio/audio.rs | UTF-8 | 5,531 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::engine::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = ["window", "howler_bindings"], js_name = loadAudio)]
fn load_audio(src: &str, ios: bool);
#[wasm_bindgen(js_namespace = ["window", "howler_bindings"], js_name = play)]
fn play(src: &str);
#[wasm_b... | true |
65e9321dab5aecf0cf6684ee5742b3c5f2dcb9f5 | Rust | dennisss/dacha | /pkg/crypto/src/ccm.rs | UTF-8 | 11,234 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | // Implementation of the AEAD CCM cipher as described in:
// https://datatracker.ietf.org/doc/html/rfc3610
//
// NOTE: Currently only fixed block sizes are supported.
use core::result::Result;
use common::ceil_div;
use crate::constant_eq;
use crate::utils::xor_inplace;
/// Number of bytes in an AES-128 key.
pub con... | true |
9f46d3faef6106a1ddb6e04e912bd745afe9c6e7 | Rust | jakmeier/div-rs | /src/error.rs | UTF-8 | 2,782 | 3.125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::error::Error;
use std::fmt;
#[derive(Debug)]
/// Generic error type for all library calls which may fail.
///
/// Having a common type for all errors can vastly simplify all kinds of call-chains.
pub enum DivError {
UseAfterDelete,
NotAllocated,
NotInitialized,
AlreadyInitialized,
Locked,
... | true |
ed82558dfe6c4946314d6b3eb724949916b89fcd | Rust | NopSandBits/covid-respirator | /src/software/control/src/display/drawer.rs | UTF-8 | 2,617 | 2.71875 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | // MakAir
//
// Copyright: 2020, Makers For Life
// License: Public Domain License
use gfx_core::Resources;
use piston_window::image::Image;
use piston_window::{Glyphs, Text, Texture, Event, PistonWindow};
use std::path::{Path, PathBuf};
struct DisplayDrawerLoaderBuilder;
pub struct DisplayDrawerLoader {
// pub... | true |
44bf178b6d1172d6e6204eb180523c6d6d3bcec0 | Rust | ebkalderon/appstream | /src/field/category.rs | UTF-8 | 1,898 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashMap;
use std::ops::Deref;
use std::str::FromStr;
use super::Field;
const CATEGORIES: &[&str] = &[
"Audio",
"AudioVideo",
"Development",
"Education",
"Game",
"Graphics",
"Network",
"Office",
"Science",
"Settings",
"System",
"Utility",
"Video... | true |
7076b1f2855fdb0e818b66fa5d1ed7e907d12e83 | Rust | dimitri-br/gameboy | /src/_cpu/read_rom.rs | UTF-8 | 614 | 3.09375 | 3 | [] | no_license | //file reads rom from file
use std::fs::File;
use std::io::{Read, stdin};
pub struct ROM{
pub path: String,
pub content: Vec::<u8> //ROM buffer - TODO - INCREASE!!! :D
}
impl ROM{
pub fn new(path: String) -> Self{
ROM {
path: path,
content: Vec::<u8>::new(),
}
}... | true |
291fda840b267232e77609d058d1842ad09a5220 | Rust | leejw51crypto/RustChainIndexer | /RustChainIndexer/src/proto/cosmos.tx.v1beta1.rs | UTF-8 | 9,521 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | /// Tx is the standard type used for broadcasting transactions.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Tx {
/// body is the processable content of the transaction
#[prost(message, optional, tag = "1")]
pub body: ::std::option::Option<TxBody>,
/// auth_info is the authorization related ... | true |
2560ea8f741a4152760226490d3124eb47adec8e | Rust | tock/tock | /capsules/extra/src/text_screen.rs | UTF-8 | 10,948 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.
//! Provides userspace with access to the text screen.
//!
//! Usage:
//! -----
//!
//! You need a screen that provides the `hil::text_screen::TextScreen`
//! trait.
... | true |
3eaee00e3124aac526393e6486cd62392b721c3a | Rust | mehcode/config-rs | /src/ser.rs | UTF-8 | 17,387 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt::Display;
use serde::ser;
use crate::error::{ConfigError, Result};
use crate::value::{Value, ValueKind};
use crate::Config;
#[derive(Default, Debug)]
pub struct ConfigSerializer {
keys: Vec<(String, Option<usize>)>,
pub output: Config,
}
impl ConfigSerializer {
fn serialize_primitive<T>(&mu... | true |
fc09827d72e00552f860301281a2d93bb7f7c24e | Rust | thebigjc/adventofcode-2019 | /day7/src/main.rs | UTF-8 | 6,720 | 3.1875 | 3 | [] | no_license | use itertools::Itertools;
use std::fs;
use std::i32;
use std::collections::VecDeque;
fn parse(s: &str) -> i32 {
s.trim().parse().unwrap()
}
fn position(t: &Vec<i32>, i: usize) -> i32 {
t[t[i] as usize] as i32
}
fn immediate(t: &Vec<i32>, i: usize) -> i32 {
t[i] as i32
}
fn mode(m: i32) -> fn(&Vec<i32>, ... | true |
699c8172835c84ed4ffc344ac42dd3bf3bd1af02 | Rust | ThinkChaos/rtsp-rs | /rtsp-2/src/header/types/public.rs | UTF-8 | 5,376 | 3.015625 | 3 | [
"MIT"
] | permissive | use itertools::Itertools;
use linked_hash_set::LinkedHashSet;
use std::convert::TryFrom;
use std::iter::{once, FromIterator};
use std::ops::{Deref, DerefMut};
use crate::header::map::TypedHeader;
use crate::header::name::HeaderName;
use crate::header::value::HeaderValue;
use crate::method::{Method, MethodError};
use c... | true |
40190f7fd8e0d8635da208c074227aa20ae621db | Rust | vmx/remtiski | /src/main.rs | UTF-8 | 2,620 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use libremarkable::framebuffer::common::{
color, display_temp, dither_mode, mxcfb_rect, waveform_mode, DISPLAYHEIGHT, DISPLAYWIDTH,
};
use libremarkable::framebuffer::core::Framebuffer;
use libremarkable::framebuffer::{FramebufferBase, FramebufferIO, FramebufferRefresh};
use tiny_skia::{Canvas, LineCap, LineJoin, P... | true |
b05e93e2f6264279e49715d25c218485c409cb17 | Rust | brokay02/solana-token-registry | /program/src/error.rs | UTF-8 | 6,548 | 2.921875 | 3 | [] | no_license | use num_derive::FromPrimitive;
use solana_program::{
decode_error::DecodeError,
msg,
program_error::{PrintProgramError, ProgramError},
};
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum RegistryError {
#[error("The registry has not yet been initialized.")]
... | true |
52707556d66fd8f8dfb1f4754769e90506e22c98 | Rust | mnts26/aws-sdk-rust | /sdk/aws-config/src/meta/region.rs | UTF-8 | 5,756 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
//! Region providers that augment existing providers with new functionality
use aws_types::region::Region;
use std::borrow::Cow;
use std::fmt::Debug;
use tracing::Instrument;
/// Load a region by sele... | true |
aa18f610523281ac254cb51c10f0be590b923bee | Rust | ajit-kolathur/AdventOfCode | /src/days/day2.rs | UTF-8 | 5,837 | 3.296875 | 3 | [] | no_license | use std::time::Instant;
use std::path::Path as Path;
use crate::common::io;
struct PasswordRule {
min: i8,
max: i8,
character: char
}
type PasswordEntry = (String, PasswordRule);
// Parse a line to extract PasswordRule or fail
fn parse_rule_string(rule_string: &str) -> Result<PasswordRule, &'static str>... | true |
9584a1ee1d303841f2ed6b22c934ffdb1fa08783 | Rust | chengluyu/codewars | /rust/4kyu/range-extraction.rs | UTF-8 | 704 | 2.671875 | 3 | [
"MIT"
] | permissive | mod solution {
pub fn range_extraction(a: &[i32]) -> String {
let mut ranges: Vec<(i32, i32)> = vec![];
for &value in a {
if ranges.is_empty() {
ranges.push((value, value));
} else if ranges.last().unwrap().1 + 1 == value {
let begin = ranges.p... | true |
bfde04b78f675a348837bbc49ba5d5d523c48dee | Rust | MukundhBhushan/rust-tots | /functions/func_with_ret.rs | UTF-8 | 129 | 3.40625 | 3 | [] | no_license | fn main(){
let res = is_even(10);
println!("the number is {}",res);
}
fn is_even(no:u32)->bool{
return no%2 == 0;
} | true |
f7c60a1d5abb448793b9dd2e003ee5f69fe55965 | Rust | oxidecomputer/third-party-api-clients | /slack/src/admin_emoji.rs | UTF-8 | 4,167 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::Client;
use crate::ClientResult;
pub struct AdminEmoji {
pub client: Client,
}
impl AdminEmoji {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
AdminEmoji { client }
}
/**
* This function performs a `POST` to the `/admin.emoji.add` endpoint.
*
* Add an emoji... | true |
29197d1780604738172930c74651c0c078b07c5a | Rust | Oyelowo/coding_practice | /rust/guessing_game_/src/exercises.rs | UTF-8 | 245 | 2.8125 | 3 | [] | no_license | fn main() {
/* Convert temperatures between Fahrenheit and Celsius.
Generate the nth Fibonacci number.
Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” taking advantage of the repetition in the song. */
}
| true |
bafcb205fa86f47244a4ebb877798c9839e89440 | Rust | scifi6546/worthington | /file_table/src/lib.rs | UTF-8 | 8,329 | 3.21875 | 3 | [] | no_license | #[macro_use]
extern crate anyhow;
use anyhow::Result;
use thiserror::Error;
use traits::{Extent, InsertableDyn};
#[derive(Error, Debug)]
enum TableError {
#[error("Key is out of range")]
KeyOutOfRange,
#[error("Key Unused: (#key)")]
KeyUnused { key: Key },
#[error("Invalid Extent size(#size)")]
... | true |
880f8508dcc3a7e0898aab498ea3bd0fd7bb61ba | Rust | fxbox/openzwave-rust | /openzwave-sys/src/value_classes/value_id.rs | UTF-8 | 2,106 | 2.890625 | 3 | [] | no_license | #[repr(C)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum ValueGenre {
ValueGenre_Basic = 0,
ValueGenre_User,
ValueGenre_Config,
ValueGenre_System,
ValueGenre_Count
}
#[repr(C)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum ValueType {
ValueType_Bool = 0,
ValueType_Byte,
ValueTyp... | true |
58526061089f2e3a0484655ab217545810039deb | Rust | S-YOU/rust-book-minigrep | /src/lib.rs | UTF-8 | 4,071 | 3.59375 | 4 | [] | no_license | // 環境変数を扱う
use std::env;
// std::fs::File ファイルを扱うのに必要
// std::io::prelude::* ファイル入出力を含む入出力処理をする
use std::fs::File;
use std::io::prelude::*;
// エラー型を扱うError トレイト
use std::error::Error;
// 設定値
pub struct Config {
pub query: String,
pub filename: String,
pub case_sensitive: bool,
}
impl Config {
// 成功時... | true |
132f9117e969af97f68658401b2be3bb3aab4a55 | Rust | giodamelio/little_boxes | /vendor/winnow/src/stream/impls.rs | UTF-8 | 13,382 | 2.875 | 3 | [
"MIT"
] | permissive | macro_rules! impl_partial_eq {
($lhs:ty, $rhs:ty) => {
impl<'a, 'b> PartialEq<$rhs> for $lhs {
#[inline]
fn eq(&self, other: &$rhs) -> bool {
let l = self.as_ref();
let r: &Self = other.as_ref();
PartialEq::eq(l, r)
}
... | true |
66f2e23fc2d7753379b6bdeb7c72d2be7af8cb03 | Rust | jeremyandrews/ftest | /src/main.rs | UTF-8 | 3,704 | 3.390625 | 3 | [] | no_license | /// This repo is to ask some questions about how to store
/// async futures to invoke later, for use with Goose:
/// https://github.com/tag1consulting/goose
///
/// Currently Goose is not async, and instead stores function
/// pointers.
///
/// The definition is quite simple:
/// https://github.com/tag1consulting/goo... | true |
15c4d2c6968e9c1e839700ccf930ec19cb138929 | Rust | Mesoptier/advent-of-code-2020 | /src/bin/day11.rs | UTF-8 | 3,493 | 3.21875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead};
use itertools::Itertools;
use std::cmp::{max, min};
fn main() {
let file = File::open("input/day11.txt").unwrap();
let buf_reader = BufReader::new(file);
let mut grid: Vec<Vec<char>> = vec![];
for line in buf_reader.lines() {
let mut row: ... | true |
d05fc74f81db88a102fe2a7e45e1803f45e72818 | Rust | lukecashwell/olcCodeJam2019-CoreDestroyer | /src/game/BounceBomb.rs | UTF-8 | 3,088 | 2.609375 | 3 | [] | no_license | pub struct BounceBomb {
x: f32,
y: f32,
xv: f32,
yv: f32,
life_time: u32,
bounce_count: u32,
is_dead: bool,
animation_frame: u32
}
impl BounceBomb {
pub fn new(x: f32, y: f32, xv: f32, yv: f32) -> Self {
Self{x: x, y: y, xv: xv, yv: yv, life_time: 1000, is_dead: false, animation_frame: 0, bounc... | true |
bdaecf2d90b466c8e0c9ba80d73a32fccda81d6b | Rust | alvr-org/ALVR | /alvr/dashboard/src/dashboard/basic_components/modal.rs | UTF-8 | 1,881 | 2.75 | 3 | [
"MIT",
"Unicode-DFS-2016",
"BSD-3-Clause",
"CC0-1.0",
"BSL-1.0",
"Apache-2.0",
"OFL-1.1",
"BSD-2-Clause",
"zlib-acknowledgement",
"LLVM-exception",
"MPL-2.0",
"Unlicense"
] | permissive | use eframe::egui::{Align, Align2, Layout, Ui, Window};
pub enum ModalResponse {
Ok,
Cancel,
}
pub fn modal(
ui: &mut Ui,
title: &str,
content: impl FnOnce(&mut Ui, f32), // arg 2: available width
do_not_show_again: Option<&mut bool>,
visible: &mut bool,
) -> Option<ModalResponse> {
let... | true |
0ef5ea3237af458cc1d0e2b0e6c08099e24916c9 | Rust | WarmBeer/rust-blocklattice | /src/account.rs | UTF-8 | 1,866 | 3.109375 | 3 | [] | no_license | use crate::block::Block;
use crate::{Address, Height, BlockType};
use std::collections::HashSet;
#[derive(Clone, Debug)]
pub struct Account {
pub address: Address,
pub balance: u64,
pub blockchain: Vec<Block>,
pub pending_blocks: HashSet<String>
}
impl Account {
pub(crate) fn new (address: &str) -... | true |
0fb011e983e6c3ca108f25f86e35e1f23dcc3ad9 | Rust | hch12907/wiz | /src/error.rs | UTF-8 | 4,637 | 3.375 | 3 | [
"BSD-3-Clause"
] | permissive | use reqwest;
use std::error::Error as StdError;
use std::fmt;
use std::io;
use std::string::FromUtf8Error;
use toml::de::Error as TomlDeserializeError;
use toml::ser::Error as TomlSerializeError;
/// The error type for the program's every operations, such as TOML Parsing
/// or IO-related errors. Wherever there's an e... | true |
d0870525b6f431e98952fab56e78290929789efe | Rust | Dyr-El/advent_of_code_2017 | /niklasad1-rust/Day8/tests/day8.rs | UTF-8 | 461 | 2.515625 | 3 | [] | no_license | extern crate day8;
#[test]
fn test_simple() {
if let Ok(input) = day8::ReadFile::read_file_to_string("test.txt") {
let lines = input.lines().collect::<Vec<_>>();
assert_eq!((1, 10), day8::Cpu::new(&lines).run());
}
}
#[test]
fn test_all() {
if let Ok(input) = day8::ReadFile::read_file_to_st... | true |
c038046ba1fcaba02dfdc48b8576750a87ee3320 | Rust | trsoluti/MetalByExample-Rust | /Common/metal_kit/src/metal_kit/metal_clear_colors.rs | UTF-8 | 1,668 | 2.859375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //
// metal_clear_color.rs
//
// Created by TR Solutions on 2020-07-12.
// Copyright © 2020 TR Solutions Pte. Ltd.
// Licensed under Apache 2.0 and MIT
// See appropriate LICENCE files for details.
//
//! Thin wrappers for MTLClearColor struct and associated data
use std::os::raw::c_double;
use objc::{Encode, Enc... | true |
01b5d4728f3573e4b8253119469115c734e7a804 | Rust | wotsushi/competitive-programming | /agc/012/b.rs | UTF-8 | 2,540 | 2.796875 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
let (N, M): (usize, usize) = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut iter = line.split_whitespace();
(
iter.next().unwrap().pars... | true |
a6f6d9686b36aa203d1270e54dff6bb560ba036a | Rust | rust-ndarray/ndarray-examples | /linear_regression/src/lib.rs | UTF-8 | 3,465 | 3.25 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![allow(non_snake_case)]
use ndarray::{stack, Array, Array1, ArrayBase, Axis, Data, Ix1, Ix2};
use ndarray_linalg::Solve;
/// The simple linear regression model is
/// y = bX + e where e ~ N(0, sigma^2 * I)
/// In probabilistic terms this corresponds to
/// y - bX ~ N(0, sigma^2 * I)
/// y | X, b ~ N(bX,... | true |
3de508bdfded27000ce0dfe0684afeb70dffeabc | Rust | xadozuk/cryptopals-rust | /src/lib/traits/mod.rs | UTF-8 | 632 | 2.96875 | 3 | [] | no_license | use std::string::FromUtf8Error;
use crate::lib::iterators::BlockIterator;
pub trait Bitable
{
fn bit(&self, n: usize) -> u8;
fn bits(&self) -> Vec<u8>;
}
pub trait FromHex
{
fn from_hex(string: &str) -> Self;
}
pub trait ToHex
{
fn to_hex(&self) -> String;
}
pub trait FromBase64
{
fn from_base6... | true |
57279175ef9889935bfabdf8a0a3d178321cc003 | Rust | stoneflyop1/wasm-demo | /src/mem/jsval.rs | UTF-8 | 935 | 3.03125 | 3 | [
"MIT"
] | permissive | // https://rustwasm.github.io/wasm-bindgen/reference/arbitrary-data-with-serde.html
use wasm_bindgen::prelude::*;
use std::collections::HashMap;
use crate::imports::log;
/// struct used to convert to and from JsValue
#[derive(Serialize, Deserialize)]
pub struct StructExample {
pub name: String,
pub props: Ha... | true |
00c19a2296f61b9fa52cb6caf18bf4590c2971c2 | Rust | olignyf/signal-gen-cjds66 | /signal-gen-cjds66-lib/src/command_test.rs | UTF-8 | 23,668 | 2.625 | 3 | [
"MIT"
] | permissive | /* Copyright © 2020-2021 Jeremy Carter <jeremy@jeremycarter.ca>
By using this software, you agree to the LICENSE TERMS
outlined in the file titled LICENSE.md contained in the
top-level directory of this project. If you don't agree
to the LICENSE TERMS, you aren't allowed to use this
software.
*/
/*! Unit Tests */
... | true |
309964f1b44683440c143871203e4665075386b0 | Rust | boa-dev/boa | /boa_engine/src/value/integer.rs | UTF-8 | 3,572 | 3.890625 | 4 | [
"MIT",
"Unlicense"
] | permissive | use std::cmp::Ordering;
/// Represents the result of the `ToIntegerOrInfinity` operation
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum IntegerOrInfinity {
/// Positive infinity.
PositiveInfinity,
/// An integer.
Integer(i64),
/// Negative infinity.
NegativeInfinity,
}... | true |
e928ac9219f173380749f29e6bc6e16c56d87367 | Rust | rlingineni/chessmarkable | /src/square.rs | UTF-8 | 3,819 | 3.359375 | 3 | [
"MIT"
] | permissive | pub use crate::game::SQ;
use crate::game::{File, Rank};
use anyhow::{Context, Result};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_string_derive::SerdeDisplayFromStr;
use std::fmt;
use thiserror::Error;
const FILES: &[char] = &['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
const RANKS: &[char] ... | true |
f35b954c2c7be963057b4cbb1446e71c1b958867 | Rust | JacobSchneck/mult-thread-mat-mult | /src/matrix_add.rs | UTF-8 | 384 | 2.859375 | 3 | [] | no_license | #![allow(non_snake_case)]
use crate::matrix::Matrix;
pub fn matrix_add(A: &Matrix, B: &Matrix) -> Result<Matrix, String> {
if A.m != B.m && A.n != B.n {
return Err("Matrix shapes do not match".to_string());
}
let mut result = vec![vec![0; A.n]; A.m];
for i in 0..A.m {
for j in 0..B.m {
result[i][j] = A.ma... | true |
1068dc72b8161836f79d0a8532483d11c8f97f89 | Rust | cassiemeharry/raspberry-pi-forth-os | /src/rpi/mailbox.rs | UTF-8 | 10,074 | 2.859375 | 3 | [] | no_license | // use byteorder::{ByteOrder, NativeEndian};
use core::{
convert::TryInto,
fmt, mem, ops, slice,
sync::atomic::{fence, Ordering},
};
use field_offset::offset_of;
use super::mmu::align_up;
const MAIL_BASE: usize = 0xB880;
const MAIL_FULL: u32 = 0x8000_0000;
const MAIL_EMPTY: u32 = 0x4000_0000;
// const M... | true |
ecd29366d7df497e27cc9171b0b3e89aceb2d46d | Rust | yurapyon/maru.rs | /src/gfx/texture.rs | UTF-8 | 3,893 | 3.078125 | 3 | [
"MIT"
] | permissive | use gl::{
self,
types::*,
};
use image::{
RgbaImage,
};
//
// TODO
// buffer data
/// Simple wrapper around an OpenGL texture.
#[derive(Debug)]
pub struct Texture {
texture: GLuint,
width: i32,
height: i32,
}
impl Texture {
/// Create a new texture from an RgbaImage.
pub fn new(imag... | true |
f5272e86704143aa46758c4bb40ddeb8d674572e | Rust | gabdube/native-windows-gui | /native-windows-gui/examples/embed_resources/src/main.rs | UTF-8 | 3,033 | 2.703125 | 3 | [
"MIT"
] | permissive | /*!
A very simple application that show your name in a message box.
Use a manifest file to load control style and requires admin priviledge to start.
For more info about resources see https://docs.microsoft.com/en-us/windows/win32/menurc/resource-definition-statements
*/
extern crate native_windows_gui a... | true |
1af158e6aade3d565bad85920177e09fb08d6329 | Rust | Goncalerta/proc-quote | /src/lib.rs | UTF-8 | 16,792 | 3.921875 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! This crate provides the [`quote!`] macro for turning Rust syntax tree data
//! structures into tokens of source code.
//!
//! [`quote!`]: macro.quote.html
//!
//! Procedural macros in Rust receive a stream of tokens as input, execute
//! arbitrary Rust code to determine how to manipulate those tokens, and produce
/... | true |
289bc413d21d0c28ac6a499bd9079e3a8066bba4 | Rust | KrekBuk/chess-rs | /src/http/proto.rs | UTF-8 | 6,236 | 2.734375 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use serde_json::Value;
use serenity::async_trait;
use tokio::sync::RwLockWriteGuard;
use crate::chess::board::Color;
use crate::chess::pieces::Type;
use crate::http::http_server::UserInfo;
use crate::system::game::{Game, GameManager};
use crate::chess::game::{Game as ChessGame, Ga... | true |
3a369dcb9c9bf8938977929286d0b1a231852855 | Rust | cojna/contest | /codeforces/402/a.rs | UTF-8 | 1,913 | 3.140625 | 3 | [] | no_license | #![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::*;
use std::collections::*;
fn main() {
let n = readln();
let xs: Vec<usize> = readln();
let ys: Vec<usize> = readln();
let mut fx: Vec<usize> = vec![0;6];
let mut fy: Vec<usize> = vec![0;6];
let mut freq: Vec<usize> = vec![0;6];
... | true |
cdfb6c5167402215dd5471555f30670db2855631 | Rust | brianoflondon/hydra | /src/main.rs | UTF-8 | 6,360 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt;
use std::time::SystemTime;
use rusqlite::{ Connection };
use reqwest::header;
//##: Global definitions
static USERAGENT: &str = "Hydra (PodcastIndex)/v0.1";
struct Podcast {
id: u64,
url: String,
title: String
}
#[derive(Debug)]
struct HydraError(String);
//##: Impleme... | true |
2262eb46d7adb286ed4d0825c754623ddd65aad8 | Rust | oconnor663/atomic_examples | /ordering/src/main.rs | UTF-8 | 1,208 | 2.90625 | 3 | [] | no_license | use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{mpsc, Arc, Barrier};
const MY_ORDERING: Ordering = Ordering::Relaxed;
static A: AtomicBool = AtomicBool::new(false);
static B: AtomicBool = AtomicBool::new(false);
fn main() {
let barrier = Arc::new(Barrier::new(3));
let barrier1 = barrier.clone... | true |
044c0118f9ea4dfa61c75f7dae4af6e07b3a7858 | Rust | zakaluka/DailyCodingProblems | /src/aoc2019_2/src/lib.rs | UTF-8 | 2,181 | 3.578125 | 4 | [] | no_license | /// Program model.
#[derive(Default)]
pub struct Model {
pub int_code: Vec<i64>,
}
impl Model {
/// Get a value from the model at the given position.
pub fn get(&self, position: usize) -> i64 { self.int_code[position] }
/// Set a value on the model.
pub fn set(&mut self, position: usize, value: i64) {
s... | true |
fd6b9fd3e473a69b61776af836b28570df9a9a0c | Rust | clucompany/Cycle_match | /tests/loop_match.rs | UTF-8 | 663 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive |
#[macro_use]
extern crate cycle_match;
#[test]
fn loop_match() {
let data = b"123456789";
let mut num = 0usize;
let mut iter = data.iter();
loop_match!((iter.next()) -> || {
Some(b'0') => {},
Some(a @ b'1' ..= b'9') => {
num *= 10;
num += (a - b'0') as usize;
},
Some(a) => panic!("Unk byte: {:?}... | true |
49c964c8c4ed150bf3b48d16950fecf62f0c015a | Rust | Juici/strife | /src/model/permissions.rs | UTF-8 | 4,478 | 2.6875 | 3 | [
"MIT"
] | permissive | //! Models the bitwise permissions [flags] used by Discord to store
//! [permissions].
//!
//! [flags]: https://discordapp.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
//! [permissions]: https://discordapp.com/developers/docs/topics/permissions#permissions
#![allow(clippy::unreadable_lit... | true |
904e1d3f218456478457396e26215a1fc9ecb858 | Rust | BartMassey/mixed-strategies-rs | /tests/tests.rs | UTF-8 | 3,358 | 2.546875 | 3 | [
"MIT"
] | permissive | // Copyright © 2019 Bart Massey
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.
use ndarray::prelude::*;
use mixed_strategies::*;
#[cfg(test)]
fn eg_schema() -> Schema {
let m = vec![
vec![6.0, 0.0, 3.0... | true |
afac71f28c99457e98462dabd7ef811b27ed99a8 | Rust | zeta0134/rusticnes-core | /src/apu/pulse.rs | UTF-8 | 6,877 | 2.59375 | 3 | [
"MIT"
] | permissive | use super::length_counter::LengthCounterState;
use super::volume_envelope::VolumeEnvelopeState;
use super::audio_channel::AudioChannelState;
use super::audio_channel::PlaybackRate;
use super::audio_channel::Volume;
use super::audio_channel::Timbre;
use super::ring_buffer::RingBuffer;
use super::filters;
use super::filt... | true |
86d3f6124acb55bcfd2428aa0728aaf96fb4d98a | Rust | facebookincubator/antlir | /antlir/btrfs_send_stream_upgrade/src/mp/send_elements/command_batch_info.rs | UTF-8 | 9,935 | 2.65625 | 3 | [
"MIT"
] | permissive | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::fmt::Debug;
use std::fmt::Display;
use std::sync::Arc;
use crate::mp::sync::ordered_element::OrderedElement;
use crate:... | true |
eed178c6bb428404a3b62354acded94a72f98caa | Rust | esensar/advent-of-code | /2022/15/src/main.rs | UTF-8 | 3,660 | 3.15625 | 3 | [] | no_license | use std::{
collections::{HashMap, HashSet},
fs::File,
io::{BufRead, BufReader, Lines},
};
type Position = (i64, i64);
trait ManhattanDistance {
fn distance(&self, other: &Self) -> u64;
}
impl ManhattanDistance for Position {
fn distance(&self, other: &Self) -> u64 {
self.0.abs_diff(other.... | true |
2e8111982dab8fd79a66507361d5f2641e7e2ab7 | Rust | webdesserts/projects-cli | /src/commands/list.rs | UTF-8 | 1,014 | 2.875 | 3 | [] | no_license | use crate::config::{Config, ProjectRootSet, ProjectSet};
use crate::utils;
use failure::Error;
use std::fs;
pub fn list(paths: bool, config: Config) -> Result<(), Error> {
let paths = if paths {
list_roots(&config)?
} else {
list_projects(&config)?
};
let sorted_paths = utils::sort_set(... | true |
c4a7ff8ea4fdc7299a8ed32ef9d287f2bfa9bac7 | Rust | ytyaru/Rust.IntoIterator.20190723075030 | /src/into_iterator/src/main.rs | UTF-8 | 1,489 | 3.546875 | 4 | [
"CC0-1.0"
] | permissive | struct Pixel {
r: i8,
g: i8,
b: i8,
}
impl IntoIterator for Pixel {
type Item = i8;
type IntoIter = PixelIntoIterator;
fn into_iter(self) -> Self::IntoIter {
PixelIntoIterator {
pixel: self,
index: 0,
}
}
}
struct PixelIntoIterator {
pixel: Pixel,
... | true |
11091af3da86c05f365ae3d257a6c678ab10ea13 | Rust | prz23/zinc | /zinc-syntax/src/parser/expression/path.rs | UTF-8 | 4,234 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The path expression parser.
//!
use std::cell::RefCell;
use std::rc::Rc;
use zinc_lexical::Lexeme;
use zinc_lexical::Symbol;
use zinc_lexical::Token;
use zinc_lexical::TokenStream;
use crate::error::ParsingError;
use crate::parser::expression::structure::Parser as StructureExpressionParser;
use crate::parser... | true |
c1f5c6a420df4c22745349814ab3aa0a06a2787e | Rust | KizzyCode/checked_array-rust | /src/preallocated.rs | UTF-8 | 3,369 | 3.421875 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | use crate::{
misc::BufferTooSmall, traits::CanAlloc,
std::{ mem, cmp }
};
/// A wrapper that implements `CanAlloc` over a preallocated buffer
pub struct Preallocated<Buffer> {
/// The wrapped buffer
buffer: Buffer,
/// The amount of bytes used
used: usize
}
impl<Buffer> Preallocated<Buffer> {
... | true |
b2321f604890a507e92e9caf43cb5b6f3c52703b | Rust | kaisellgren/comp_sci.rs | /src/lib.rs | UTF-8 | 6,285 | 3.34375 | 3 | [] | no_license | //! This project consists of articles, data structures, algorithms and solutions to common problems.
//!
//! # Sorting algorithms
//!
//! Algorithm | Best case | Average case | Worst case | Auxiliary space
//! :-------- | :-------: | :----------: | :--------: | :-------------:
//! Selection sort | O(n^2) | O(n^2) | O(n... | true |
c1301f39f6ad85a5ebd68f4da8385d86c61ff09e | Rust | HazyAlex/org_parser | /src/lib.rs | UTF-8 | 12,686 | 3.21875 | 3 | [] | no_license | use serde::ser::{SerializeSeq, SerializeStruct};
use serde::{Serialize, Serializer};
#[derive(Serialize)]
pub struct Parser {
options: Vec<Options>,
headers: Arena,
}
#[derive(Debug)]
pub struct Arena {
nodes: Vec<Node>,
}
impl Arena {
pub fn new_node(&mut self, data: Header) -> NodeId {
let ... | true |
2e0ad275d0c1372165705c49a24566688dc13119 | Rust | tomoyuki-nakabayashi/MyPlayGround | /RustByExample/01.HelloWorld/print_debug/src/main.rs | UTF-8 | 836 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt;
#[derive(Debug)]
struct Structure(i32);
impl fmt::Display for Structure {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Structure(num) = self;
write!(f, "{}", num)
}
}
#[derive(Debug)]
struct Deep(Structure);
impl fmt::Display for Deep {
fn fmt(&self, f: &mut f... | true |
00f678b5a0c5aa4c9fec7bb3b5146b31cc314336 | Rust | kiskoza/30days-of-rust | /day1/src/main.rs | UTF-8 | 292 | 2.953125 | 3 | [] | no_license | #[macro_use] extern crate text_io;
fn main() {
let i = 4;
let d = 4.0;
let s = "HackerRank ";
// read the values
let i2: i32 = read!();
let d2: f32 = read!();
let s2: String = read!("{}\n");
println!("{}", i + i2);
println!("{:.1}", d + d2);
println!("{}{}", s, s2);
}
| true |
4cdd82da49579124de689829edebb50fea0b9496 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/futures/tests/ready_queue.rs | UTF-8 | 4,294 | 2.71875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use
futures
:
:
channel
:
:
oneshot
;
use
futures
:
:
executor
:
:
{
block_on
block_on_stream
}
;
use
futures
:
:
future
;
use
futures
:
:
stream
:
:
{
FuturesUnordered
StreamExt
}
;
use
futures
:
:
task
:
:
Poll
;
use
futures_test
:
:
task
:
:
noop_context
;
use
std
:
:
panic
:
:
{
self
AssertUnwindSafe
}
;
use
std
:
... | true |
51ca0f67faba46802dfbc215545a167c4e34ad84 | Rust | alekratz/cryptopals | /src/common.rs | UTF-8 | 2,836 | 3.34375 | 3 | [] | no_license | use base64;
use std::{collections::HashMap, slice, str};
pub type FrequencyMap = HashMap<u8, f64>;
pub fn bytes_ascii(bytes: &[u8]) -> String {
bytes.iter().copied().map(|b| b as char).collect()
}
pub fn bytes_hex(bytes: &[u8]) -> String {
bytes.iter().map(|byte| format!("{:02x}", byte)).collect()
}
pub fn ... | true |
43c002774917cef6cadb333ae5ceee80db0d108c | Rust | hwasurr/rust-basic-study | /src/vectors.rs | UTF-8 | 1,330 | 4.09375 | 4 | [] | no_license | use std::mem;
pub fn run() {
// Vectors Resizable Arrays
let numbers: Vec<i32> = vec![1, 2, 3, 4, 5];
// 타입이 통일되어야 한다.
println!("{:?}", numbers);
// Get single val
println!("single val[0]: {}", numbers[0]);
// Mutable Vector - 타입에 맞추어서 변경만 가능
let mut mutable_numbers: Vec<i32> = vec!... | true |
4a26e0909d1b49b6a1ff48e9d20295ce55e062aa | Rust | mkeeter/advent-of-code | /2021/23/src/main.rs | UTF-8 | 5,801 | 3.078125 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::BufRead;
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
struct Map<const DEPTH: usize> {
slab: [u8; 11],
wells: [[u8; DEPTH]; 4],
locked: [[bool; DEPTH]; 4],
}
fn energy(b: u8) -> usize {
match b {
b'A' => 1,
b'B' => 10,
b'C' => 100,
... | true |
cb122331907813ac468fff573538473ea67bd609 | Rust | iurii-kyrylenko/exercism-rust | /saddle-points/src/main.rs | UTF-8 | 1,317 | 3.21875 | 3 | [] | no_license | use std::collections::{BTreeMap, BTreeSet};
fn get_max(input: &[Vec<u64>]) -> BTreeSet<(usize, usize)> {
let rows = input.len();
let cols = input[0].len();
let mut result = BTreeSet::new();
for i in 0..rows {
let mut map: BTreeMap<u64, Vec<(usize, usize)>> = BTreeMap::new();
for j in ... | true |
e776fe3c099371e3144827334c97bb6a64985710 | Rust | Destrae/hhvm | /hphp/hack/src/hhbc/string_utils.rs | UTF-8 | 7,910 | 2.703125 | 3 | [
"MIT",
"PHP-3.01",
"Zend-2.0"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
extern crate lazy_static;
use escaper::*;
use lazy_static::lazy_static;
use naming_special_names_rust::{classes, members};
use regex::R... | true |
3dc40d209c796c81f5ffe0467cf86a42b7c9b354 | Rust | glitch4347/chess | /src/state.rs | UTF-8 | 7,518 | 2.6875 | 3 | [] | no_license | use macroquad::prelude::*;
use crate::piece::{Piece, PieceType};
use crate::types::Color;
pub struct Cell {
pub color: Color,
pub piece: Option<Piece>,
pub active: bool,
pub selected_move: bool
}
impl Cell {
pub fn new(color: Color, piece: Option<Piece>) -> Cell {
return Cell {
... | true |
1dd361ed73c09e507dcee129afe34ab65023c7db | Rust | nathanielsimard/mock-it | /examples/tokio.rs | UTF-8 | 1,220 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use tokio::time::sleep;
// #[cfg_attr(test, mock_it::mock_it)]
#[mock_it::mock_it]
#[async_trait::async_trait]
trait Heart {
async fn beat(&self) -> Result<bool, String>;
}
struct Jogger<H: Heart> {
pub heart: H,
}
impl<H: Heart> Jogger<H> {
fn new(heart: H) -> Self {
Sel... | true |
c852cef6becf506dac5538ba995b2c53ed2d074a | Rust | miquels/nntp-rs | /src/nntp_codec.rs | UTF-8 | 29,383 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::any::Any;
use std::convert::{TryFrom, TryInto};
use std::fmt::{self, Debug};
use std::future::Future;
use std::io;
use std::ops::Range;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;
use crate::article::Article;
use crate::arttype::ArtTypeScanner;
use crate::bus::Notification;
use... | true |
39c4c84eb0ff955e077285db7d9ef25b013a9a80 | Rust | club-code/CodingChallenges | /advent-of-code/2020/rust/day10/src/bin/part1.rs | UTF-8 | 647 | 3.25 | 3 | [] | no_license | use anyhow::Result;
use day10::parse_ratings;
/// Solves part 1 by sorting, counting the 1 and 3 differences and multiplying them.
pub fn main() -> Result<()> {
let mut ratings = parse_ratings()?;
ratings.sort_unstable();
let (ones, threes) =
(0..ratings.len() - 1).fold((0, 0), |(o, t), i| match r... | true |
ca57d9ca8b5a816f4a7dc81cd4cff032b9902966 | Rust | ivandkh/mchain | /src/mchain/tools.rs | UTF-8 | 983 | 3.328125 | 3 | [] | no_license | pub fn get_ngrams(n: usize, text: &str) -> Vec<Vec<&str>> {
let mut ngrams = Vec::new();
let words: Vec<&str> = text.split_whitespace().collect();
for i in 0..words.len() - n {
let ngram = words[i..i + n].to_vec();
ngrams.push(ngram);
}
ngrams
}
#[allow(dead_code)]
pub fn get_stop... | true |
dba5249f657edf47fb9b1e9c327a37a6fbe862ab | Rust | unship/tray_rust | /src/material/metal.rs | UTF-8 | 1,806 | 3.15625 | 3 | [
"MIT"
] | permissive | //! Provides a material for modelling metal surfaces of varying roughness
//! using the Torrance Sparrow BRDF and a Blinn microfacet distribution
//! TODO: Add Ashikman-Shirley (spelling?) anisotropic microfacet model
//!
//! # Scene Usage Example
//! The metal material requires a refractive index and absorption coeffi... | true |
6fc6acac568624c9d9f388403bfc0944c0c42a28 | Rust | JordanElButler/labyrinth | /src/boundaries.rs | UTF-8 | 841 | 3.03125 | 3 | [] | no_license |
pub struct AABB {
x: f32,
y: f32,
z: f32,
}
impl AABB {
pub fn new(x: f32, y: f32, z: f32) -> Self {
AABB {
x,
y,
z,
}
}
}
pub struct Cylinder {
y: f32,
r: f32,
}
impl Cylinder {
pub fn new(y: f32, r: f32) -> Self {
Cylinder... | true |
e7b02774e67b87ad1afe079df9d85c59fc72b072 | Rust | axos88/lpc-pac | /lpc11u6x/src/dma/ctlstat.rs | UTF-8 | 4,033 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::CTLSTAT {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = "Possible values of the field `VALIDPENDING`"]
#[de... | true |
92cdd7f998b92ce85cf7dd0b7c9a8eb20fdbf3da | Rust | novicat/My-cookbook | /rust/cli_args/src/main.rs | UTF-8 | 522 | 3.078125 | 3 | [] | no_license | //extern crate std;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
println!("{:?}", args);
println!("{}", &args[0]);
// Will not panic if it doesn't exist
let arg_five = args.get(5);
if arg_five.is_none() {
println!("No fifth arg provided")
} else if arg_f... | true |
6cde6b17069176865c28a203fd51e141675ac741 | Rust | jbowles/algos_math_comp | /basic_stats/ruststats/src/mean_variance.rs | UTF-8 | 1,215 | 3.21875 | 3 | [] | no_license | /*
1/n Σᵢxᵢ
*/
pub fn mean(s: &[f32]) -> f32 {
let mut sum = 0.0;
for v in s.iter() {
sum += *v;
}
// (1.0 / (s.len() as f32)) * sum
sum / (s.len() as f32)
}
/*
julia: sum((p .- m).^2) / length(p)
1/n Σᵢ(xᵢ - x̄)
*/
pub fn sample_variance(s: Vec<f32>) -> f32 {
let mut sum = ... | true |
df6a8c3912c586188ac26a8bdb35928475b94ad0 | Rust | jazzfool/thunderclap | /thunderclap/src/ui/mod.rs | UTF-8 | 5,988 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! The main part of Thunderclap; a widget toolkit built atop Reclutch.
pub mod button;
pub mod checkbox;
pub mod container;
pub mod hstack;
pub mod label;
pub mod margins;
pub mod max_fill;
pub mod scroll_bar;
pub mod text_area;
pub mod vstack;
#[macro_use]
pub mod core;
pub use {
button::*, checkbox::*, contai... | true |
80cd23443cd4abf76e2e86abe42528182501713f | Rust | xujihui1985/learningrust | /typeandvariable/src/main.rs | UTF-8 | 2,698 | 3.328125 | 3 | [] | no_license | use std::mem;
use std::collections::HashMap;
use std::fs::File;
mod stackheap;
mod control_flow;
const GLOBAL_CONST:u8 = 42;
static STATIC_GLOBAL:i32 = 321;
static mut STATIC_MUT_GLOBAL:i32 = 4321;
fn main() {
let a:u8 = 123; // 8bit unsigned integer
println!("a = {}",a);
let mut b = 11; // 8bit signed ... | true |
9e0ff1937824b8e8908534327d13d84ccb21c8ae | Rust | gschenk/pv_sim | /meter/src/input.rs | UTF-8 | 4,073 | 3.296875 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use std::error::Error;
use std::fs;
use toml;
const DEFAULT_FILE: &str = "default.toml";
#[derive(Debug, Clone)]
pub struct Config {
pub rabbit: Rabbit,
pub time: Time,
pub flags: Flags,
pub random: Random,
}
#[derive(Deserialize, Debug)]
pub struct TomlConfig {
pub rabbit... | true |
3865dace9978c554774b12da707e72a413731928 | Rust | dkushner/chopper | /src/render/mesh.rs | UTF-8 | 355 | 2.921875 | 3 | [
"MIT"
] | permissive | /// Manages mesh data on behalf of a RenderManager instance.
///
/// The mesh manager creates and handles mesh resources including vertex and index buffers. It does
/// not directly create a mesh component but stores the actual mesh data so that a RenderManager
/// can take advantage of mesh instancing in an agnostic w... | true |
974df51b929b76012b62cc5be48cf19d2acab961 | Rust | fan-tom/liquid-rust | /lint_plugin/src/expr.rs | UTF-8 | 8,725 | 3.046875 | 3 | [] | no_license | use rustc::{
mir::{self, Operand, Place},
ty::{TyKind, Const as RustConst},
};
use rustc_target::abi::Size;
use derive_more::*;
use crate::refinable_entity::RefinableEntity;
use rustc::hir::def_id::DefId;
use crate::typable::{Typable, Ty, Typer};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Display)]
pub ... | true |
1a5932a7fa82fdd6609bc527da9e6052d7bbe1bb | Rust | maxvinza/textcode | /tests/iso6937.rs | UTF-8 | 486 | 2.78125 | 3 | [] | no_license | use textcode::*;
#[test]
fn test_iso6937() {
let u = "iso6937 with € sign. ♪";
let c: &[u8] = &[
0x69, 0x73, 0x6f, 0x36, 0x39, 0x33, 0x37, 0x20,
0x77, 0x69, 0x74, 0x68, 0x20, 0xa4, 0x20, 0x73,
0x69, 0x67, 0x6e, 0x2e, 0x20, 0xd5,
];
let mut dst: Vec<u8> = Vec::new();
iso693... | true |
01d78961c9540d902645d04c5f288303a6a6c721 | Rust | nbrr/conifer | /examples/touch.rs | UTF-8 | 459 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use conifer::Config;
use evdev::Device;
fn main() {
let mut d = Config::new("/dev/input/event3", "/dev/fb0", 719., 1439.);
d.run(|frame, pointer, delta_time| {
if pointer.y > 1350 {
// exit if we touch bottom of screen
return true;
}
if pointer.is_down {
... | true |
fb6803a98b3e50265be39fe15fbff80e6ebf3a10 | Rust | number41/cryptopals | /src/bin/c02-fixed-xor.rs | UTF-8 | 400 | 2.578125 | 3 | [] | no_license | extern crate cryptopals;
use cryptopals::utils::{xor_buffers, decode_hex, encode_hex};
fn main() {
let lhs = "1c0111001f010100061a024b53535009181c";
let rhs = "686974207468652062756c6c277320657965";
let lhs_bytes = decode_hex(lhs);
let rhs_bytes = decode_hex(rhs);
let xor_bytes = xor_buf... | true |
2122ce56dc3b9aefc76a641fb1dc99450b269838 | Rust | krstffr/exercism.io | /rust/beer-song/src/lib.rs | UTF-8 | 1,455 | 3.328125 | 3 | [] | no_license | // POSSIBLY THE WORST CODE OF MY LIFE??
pub fn verse(n: u32) -> String {
// Bottle numbers as strings...
let low_u = if n < 1 { 0 } else { n - 1 };
let n_high = &n.to_string();
let n_low = &(low_u).to_string();
// Replace H and L with bottle numbers...
let result = String::from(
"H bott... | true |
a336e8a894fb85e3d53171342974fe224cb04dfb | Rust | K0bin/SourceRenderer | /valve_formats/bsp/src/lump_data/entity.rs | UTF-8 | 2,578 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::io::{Read, Result as IOResult};
use crate::StringRead;
pub struct Entities {
pub entities: Vec<Entity>
}
impl Entities {
pub fn read(read: &mut dyn Read) -> IOResult<Entities> {
let mut entities = Vec::<Entity>::new();
let text = read.read_null_terminated_string().u... | true |
c944c400dc6a25cf9fc9ef12927cd4498d228657 | Rust | fossabot/ktra | /src/get.rs | UTF-8 | 3,200 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::db_manager::DbManager;
use crate::models::{Query, User};
use crate::utils::*;
use futures::TryFutureExt;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::RwLock;
use warp::{filters::BoxedFilter, Filter, Rejection, Reply};
#[tracing::instrument(skip(db_manager, dl_dir_path, path))]
pub fn apis(
... | true |
14ee02b3cb17f17494ad74341eeff5bd9d1f20b1 | Rust | scarvalhojr/hashcode2021 | /src/naive.rs | UTF-8 | 1,475 | 3.046875 | 3 | [
"MIT"
] | permissive | use super::*;
use crate::sched::{Schedule, Scheduler};
use log::info;
use std::collections::HashSet;
#[derive(Default)]
pub struct NaiveScheduler {}
impl Scheduler for NaiveScheduler {
fn schedule<'a>(&self, simulation: &'a Simulation) -> Schedule<'a> {
let mut schedule = Schedule::new(simulation);
... | true |
bc218bd3604090f122e72410bf3f50c62f8ae50a | Rust | by46/journey | /src/basic/my_mod.rs | UTF-8 | 1,194 | 2.921875 | 3 | [] | no_license | use example::common;
fn private_function() {
println!("called `my_mod:private_function()`")
}
pub fn function() {
println!("called `my_mod:function")
}
pub fn indirect_access() {
println!("called `my_mod::indirect_access`");
private_function();
}
pub mod nested {
pub fn function() {
prin... | true |
c76823f3ce4e3485fbde77517d843117d043aef7 | Rust | lancelafontaine/coding-challenges | /hackerrank/security/01-functions/security-functions/rust/security-functions/src/main.rs | UTF-8 | 447 | 3.375 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let mut input = String::new();
read_line(&mut input);
let input = to_u16(input);
let result = input % 11;
println!("{}", result);
}
fn read_line(mut string: &mut String) {
let stdin = io::stdin();
stdin.lock().read_line(&mut string).expect("Could n... | true |
f600fcba1a3cc48f8f0da2a88a16f1048f7d91fa | Rust | spirali/pas | /src/render/dot.rs | UTF-8 | 4,157 | 3.140625 | 3 | [] | no_license | use std::borrow::Cow;
use std::io::Write;
use hashbrown::HashMap;
use crate::automata::Dfa;
use crate::solver::iterate_elements;
type Node = usize;
type Edge = (Node, Node);
struct Graph {
edges: Vec<Edge>,
nodes: Vec<Box<[usize]>>,
}
/// Renders a DFA representing a graph to DOT format.
/// The DFA must h... | true |
24bd5b278a2ae4fdd48e7f9988cdb3f30759638d | Rust | tyrchen/rust-training | /live_coding/tonic-live/src/client.rs | UTF-8 | 2,884 | 2.53125 | 3 | [] | no_license | use crate::pb::chat_client::ChatClient;
use crate::pb::*;
use anyhow::Result;
use arc_swap::ArcSwap;
use dashmap::DashMap;
use lazy_static::lazy_static;
use std::ops::Deref;
use std::sync::Arc;
use tonic::codegen::InterceptedService;
use tonic::metadata::AsciiMetadataValue;
use tonic::service::Interceptor;
use tonic::t... | true |
284dfd008b2e6cdf2681e9af4c36ff4b641f3294 | Rust | ddprrt/serverless-rust | /rust-lambda/src/main.rs | UTF-8 | 2,565 | 3.125 | 3 | [] | no_license | use lambda_runtime::{Context, handler_fn};
use serde_json::{Value, json};
use itertools::Itertools;
use num::{FromPrimitive, Integer};
use std::{collections::{HashMap, HashSet}};
#[derive(Debug, PartialEq, Eq)]
pub struct Palindrome {
factors: HashSet<(u64, u64)>,
value: u64,
}
impl Palindrome {
pub fn n... | true |
4d92538fc4b95dce146676299281230dbb889621 | Rust | ktmlm/storage | /src/store/traits.rs | UTF-8 | 7,588 | 2.78125 | 3 | [] | no_license | use crate::db::{IterOrder, KValue, MerkleDB};
use crate::state::{KVecMap, State};
use crate::store::Prefix;
use ruc::*;
use serde::{de, Serialize};
use std::collections::btree_map::IntoIter;
/// statable
pub trait Stated<'a, D: MerkleDB> {
/// set state
fn set_state(&mut self, state: &'a mut State<D>);
//... | true |
55a576b0def798b000f88b760cb2bd57e74f07f2 | Rust | pandoraboxchain/rustheus | /src/rpc/src/v1/types/nodes.rs | UTF-8 | 1,604 | 3.09375 | 3 | [] | no_license | use std::fmt;
use serde::{Serialize, Serializer, Deserialize, Deserializer};
use serde::de::Unexpected;
#[derive(Debug, PartialEq)]
pub enum AddNodeOperation {
Add,
Remove,
OneTry,
}
impl<'a> Deserialize<'a> for AddNodeOperation {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<... | true |
3e1331bbaf884e60446632e913d77868cb5971d0 | Rust | basp/imp | /src/cmd/lexer.rs | UTF-8 | 3,158 | 3.515625 | 4 | [
"MIT"
] | permissive | pub struct Lexer<'a> {
src: &'a [u8],
pos: usize
}
impl<'a> Lexer<'a> {
pub fn new(src: &'a [u8]) -> Lexer {
Lexer { src: src, pos: 0 }
}
fn is_ws(ch: u8) -> bool {
match ch {
b' ' => true,
b'\r' => true,
b'\n' => true,
b'\t' => true... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.