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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ffa2c1ca503c7e38ebd59f7c66accdd64f9766f7 | Rust | milesgranger/baggie | /src/baggie.rs | UTF-8 | 2,169 | 3.75 | 4 | [
"MIT"
] | permissive | use std::collections::{HashMap, hash_map::Keys};
use std::any::Any;
use std::hash::Hash;
use std::borrow::Borrow;
/// struct for collecting values of any type with a string key
#[derive(Default, Debug)]
pub struct Baggie<K>
where K: Eq + Hash
{
data: HashMap<K, Box<Any>>
}
impl<K> Baggie<K>
where K: Eq +... | true |
71eefc3037321f0fe354ba73dd0c145bc69bf4b6 | Rust | neon64/proc-macro-testcase | /src/lib.rs | UTF-8 | 2,640 | 2.8125 | 3 | [] | no_license | #![feature(proc_macro)]
extern crate proc_macro;
extern crate proc_macro2;
extern crate syn;
#[macro_use]
extern crate quote;
use proc_macro::TokenStream;
use syn::fold::{Folder, noop_fold_expr};
use syn::{parse, Expr, ExprKind, TokenTree};
#[proc_macro]
pub fn fold_mac(input: TokenStream) -> TokenStream {
let m... | true |
09637526a7827642d4d481bd3697a125140d6a94 | Rust | isgasho/pgpass | /src/bin/read-pgpass.rs | UTF-8 | 5,116 | 2.875 | 3 | [] | no_license | extern crate regex;
use std::error::Error;
use std::fs::File;
use std::path::Path;
use std::path::PathBuf;
use std::env;
use std::io::prelude::*;
use regex::Regex;
use std::fs;
#[derive(Debug, Clone)]
struct PgPassEntry {
username: String,
hostname: String,
port: String,
database: String,
passw... | true |
1d3d408846d682acec64fc8bd0924e0caac163cd | Rust | Ainevsia/Leetcode-Rust | /198. House Robber/src/main.rs | UTF-8 | 732 | 3.46875 | 3 | [
"BSD-2-Clause"
] | permissive | fn main() {
assert_eq!(Solution::rob(vec![1,2,3,1]), 4);
}
struct Solution {}
impl Solution {
// 1 dp
pub fn rob(nums: Vec<i32>) -> i32 {
if nums.len() == 0 { return 0 }
if nums.len() <= 1 { return nums[0] }
let mut dp = vec![0; nums.len()];
dp[0] = nums[0];
dp[1] ... | true |
f0c24cec1080be4c18d221a01f8f29bb560259d7 | Rust | langzime/sunflower | /src/connection.rs | UTF-8 | 3,726 | 2.53125 | 3 | [] | no_license | use std::thread;
use std::result::Result;
use std::net::ToSocketAddrs;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::rc::Rc;
use std::io::{self, Write};
use std::io::ErrorKind::WouldBlock;
use std::error::Error;
use std::io::Read;
use std::fmt::{self, Formatter};
use std::convert::From;
use std::... | true |
ac4ee2734228c7239b04438cc0c3746250907353 | Rust | sensecollective/valora | /src/geom/ellipse.rs | UTF-8 | 1,968 | 3.390625 | 3 | [
"MIT"
] | permissive | use geom::Point;
use lyon::math::Radians;
use properties::{Centered, Path};
use transforms::{Place, Scale, Translate};
#[derive(Debug, Clone)]
pub struct Ellipse {
pub center: Point,
pub width: f32,
pub height: Option<f32>,
pub rotation: Radians<f32>,
pub tolerance: Option<f32>,
}
impl Ellipse {
... | true |
48938233a025a3bcb5580f6133e3fb2074917da6 | Rust | ivanceras/memenhancer | /src/lib.rs | UTF-8 | 18,705 | 3 | 3 | [] | no_license | #![deny(warnings)]
extern crate unicode_width;
extern crate svg;
use unicode_width::UnicodeWidthStr;
use unicode_width::UnicodeWidthChar;
use svg::node::element::Circle as SvgCircle;
use svg::node::element::Text as SvgText;
use svg::Node;
use svg::node::element::SVG;
use svg::node::element::Style;
use svg::node::Text... | true |
b82fd028a860df88fa7a6ba9d94139e4e58506ee | Rust | GEDJr/simdjson-rs | /src/parsed_json_iterator.rs | UTF-8 | 3,480 | 3.0625 | 3 | [] | no_license | use super::parsed_json::{ParsedJson, JSON_VALUE_MASK};
struct ScopeIndex {
start_of_scope: usize,
scope_type: u8,
}
impl Default for ScopeIndex {
fn default() -> ScopeIndex {
ScopeIndex {
start_of_scope: 0,
scope_type: 0,
}
}
}
pub struct ParsedJsonIterator<'a>... | true |
4535d4213c85288b0ec515adebc63016352856d1 | Rust | Inky-developer/mc_utils | /mc_utils/rcon/src/de/mod.rs | UTF-8 | 1,405 | 3.015625 | 3 | [
"MIT"
] | permissive | use byteorder::{LittleEndian, ReadBytesExt};
use std::io::Cursor;
use std::io::Read;
use crate::{Error, Result};
/// Response of the minecraft server after a command was sent
#[derive(Debug)]
pub struct PacketResponse {
/// The id of the packet. Useless right now
pub packet_id: i32,
/// The response messa... | true |
2e96e722793f9e25ff2f9fbfdaddd45decd80464 | Rust | JonasOlson/i8080 | /src/pointer.rs | UTF-8 | 509 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[derive(Clone, Copy)]
pub struct Pointer(pub u16);
impl Default for Pointer {
fn default() -> Self {
Pointer(0)
}
}
impl From<u16> for Pointer {
fn from(from: u16) -> Self {
Pointer(from)
}
}
impl From<u8> for Pointer {
fn from(from: u8) -> Self {
Pointer(from as u16)
... | true |
083bc343a655fa94e6d84afe29e41095825232c0 | Rust | zmilan/tinychain | /prototype/scalar/value/number/instance.rs | UTF-8 | 45,777 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::Ordering;
use std::convert::{TryFrom, TryInto};
use std::fmt;
use std::ops::{Add, Mul, Sub};
use serde::ser::{Serialize, SerializeMap, Serializer};
use crate::class::Instance;
use crate::error;
use crate::handler::{Handler, Route};
use crate::scalar::{Link, MethodType, PathSegment, ScalarInstance, Value... | true |
fc3e37751dc530bea81185d8f700f54c7b62fd07 | Rust | isgasho/const-combinations | /src/lib.rs | UTF-8 | 3,673 | 3.84375 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! const fn combinations iter adapter
//!
//! # Examples
//!
//! ```
//! use const_combinations::IterExt;
//!
//! let mut combinations = (1..5).combinations();
//! assert_eq!(combinations.next(), Some([1, 2, 3]));
//! assert_eq!(combinations.next(), Some([1, 2, 4]));
//! assert_eq!(combinations.next(), Some([1, 3, 4])... | true |
18d39ed0c7f54969f01cfef89552ac26d6300780 | Rust | nand-nor/dedelf | /src/header.rs | UTF-8 | 80,061 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::fs::File;
use byteorder::*;
use std::io::{Read, Seek, SeekFrom};
/* Enum needed for various functions that support runtime parsing of ELF data*/
#[derive(Clone, Debug)]
pub enum ExecHeader {
ThirtyTwo(ExecHeader32),
SixtyFour(ExecHeader64)
}
#[derive(Clone, Debug)]
pub struct ExecHeader32 {
pub... | true |
4643bf2accbcf86bd1bfa93541e50ae7959a98ba | Rust | illef/pantin | /src/view/stack_panel.rs | UTF-8 | 2,251 | 2.953125 | 3 | [] | no_license | use super::*;
pub struct StackPanel<E: AsUIEvent> {
children: Vec<Box<dyn View<Event = E>>>,
bg: Option<color::Color>,
}
pub fn make_stack_panel<E: AsUIEvent>() -> StackPanel<E> {
StackPanel {
children: vec![],
bg: None,
}
}
impl<E: AsUIEvent> StackPanel<E> {
pub fn set_bg(mut sel... | true |
f5abf42437c368422794d372a8aba1996ade8786 | Rust | cannontwo/rust_learning | /fn_pointer_testing/src/main.rs | UTF-8 | 857 | 3.296875 | 3 | [] | no_license | type PotentialFunc = fn(&[String]) -> i32;
struct Holder<'a> {
names: &'a [String],
func: PotentialFunc
}
#[derive(Debug)]
struct Larger<'a> {
holders: Vec<Holder<'a>>,
}
impl<'a> std::fmt::Debug for Holder<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "Hold... | true |
c6596306052228d1683ff0f2b681fe83146b4403 | Rust | regendo/advent-of-code-2019 | /day04/src/lib.rs | UTF-8 | 2,588 | 3.359375 | 3 | [] | no_license | mod input;
fn criteria_six_digits(num: u32) -> bool {
num >= 100_000 && num <= 999_999
}
fn criteria_in_range(num: u32) -> bool {
num >= input::LOWER && num <= input::UPPER
}
fn criteria_two_same(num: u32) -> bool {
let mut num = num;
while num > 0 {
if num % 10 == num / 10 % 10 {
return true;
}
num /= ... | true |
1dfd98eb808c5fc602372acf0d88414d49e1d3f7 | Rust | canpok1/atcoder-rust | /contests/abc187/src/bin/b.rs | UTF-8 | 1,673 | 3.546875 | 4 | [] | no_license | struct Point {
x: f64,
y: f64,
}
fn main() {
let n: usize = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().parse().unwrap()
};
let mut points: Vec<Point> = Vec::new();
(0..n).for_each(|_| {
let (x, y) = {
... | true |
fb4c436c885f385dda13cdd31d533b32143352e2 | Rust | subspace/decoupled-execution-experiment | /pallets/simple-event/src/lib.rs | UTF-8 | 1,036 | 2.921875 | 3 | [
"Unlicense"
] | permissive | //! Demonstration of Event variants that use only primative types
//! These events do not use types from the pallet's configuration trait
#![cfg_attr(not(feature = "std"), no_std)]
use frame_support::{decl_event, decl_module, dispatch::DispatchResult};
use frame_system::ensure_signed;
// #[cfg(test)]
// mod tests;
... | true |
5d2664e0d15c121fba9acedf8ab7b4fef29fc2b8 | Rust | archification/guess | /src/main.rs | UTF-8 | 2,833 | 3.0625 | 3 | [] | no_license | extern crate rand;
extern crate crossterm;
mod solarized;
mod common;
use std::io::stdin;
use std::cmp::Ordering::{
Less,
Greater,
Equal
};
use rand::Rng;
use crossterm::style::{
Attribute,
ResetColor,
SetBackgroundColor,
SetForegroundColor
};
use solarized::{
BACK,
YELLOW,
ORA... | true |
7814fd2b1186b5b1560b9025b0368d6dde906568 | Rust | denoland/deno | /runtime/fs_util.rs | UTF-8 | 1,812 | 2.90625 | 3 | [
"MIT"
] | permissive | // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
pub use deno_core::normalize_path;
use std::path::Path;
use std::path::PathBuf;
#[inline]
pub fn resolve_from_cwd(path: &Path) -> Result<PathBuf, AnyError> {
if path.is_absolute... | true |
65b0e1b34a94891ddcd3b170b2d9eaa878f05d83 | Rust | arlyon/holding | /holding_kronos/src/calendar/day.rs | UTF-8 | 908 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use super::traits::DayCycle;
/// Represents a day.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Day {
seconds_in_minute: u32,
minutes_in_hour: u32,
hours_in_day: u32,
}
... | true |
7f30cbad8a175cb88203de761496c074146db5f5 | Rust | bokutotu/curs | /src/operator.rs | UTF-8 | 5,030 | 3.078125 | 3 | [] | no_license | //! Implementing an operator for an Array
use std::ops;
use super::array::Array;
use super::cublas::level1::{daxpy, saxpy};
use super::kernel::array_scalar_add::{double_array_add_scalar, float_array_add_scalar};
use super::kernel::element_wise_operator::{element_wise_devide, element_wise_product};
///////////////////... | true |
8fe9de3e4e4c02068909910dfc9e2b05d80f1e41 | Rust | horou-dsk/nes-online-server | /examples/thread-buffer/main.rs | UTF-8 | 4,446 | 3.0625 | 3 | [] | no_license | use std::time::Duration;
use std::thread;
use chrono::Local;
use std::thread::JoinHandle;
use actix::{Actor, Context, Addr, AsyncContext, Message, Handler, Running, ActorContext};
use actix_rt::System;
const MS_PER_UPDATE: f64 = 100000000.0 / 6.0;
pub struct Room {
frame_buffer: Vec<Vec<u8>>,
addr: Option<Add... | true |
fb26054c93520ee5694b67f253639fd3936fa7e5 | Rust | DaTa-/advent-of-code-2020 | /src/bin/day15_part2.rs | UTF-8 | 774 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
fn main() {
const MAX_NUMBERS: u32 = 30000000;
let input = "6,13,1,15,2,0"; // "0,3,6";
let mut input = input.split(',').rev().map(|n| n.parse().unwrap());
let mut last_num = input.next().unwrap();
let input = input.rev();
let mut spoken_count = 0;
let mut s... | true |
8f6ea80a2e908780e626e13991cb48fbde3d020e | Rust | maximeborges/svd2rust_efm32gg990 | /src/prs/swpulse.rs | UTF-8 | 9,772 | 2.734375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::SWPULSE {
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
let mut w = W::reset_value();
f(&mut w);
self.register.set... | true |
fcd7d292f04634a34c84f8f937434b452cfbe7c7 | Rust | ohazi/cryptopals | /src/set1.rs | UTF-8 | 17,184 | 3.3125 | 3 | [] | no_license | pub fn base64_encode(bytes: &[u8]) -> Result<String, &'static str> {
let mut result = String::new();
for group in bytes.chunks(3) {
let extended = match group.len() {
1 => [group[0], 0, 0],
2 => [group[0], group[1], 0],
3 => [group[0], group[1], group[2]],
... | true |
29f35c3cc75708649c82ba0b54a1d4736a48b151 | Rust | flip1995/rust-clippy | /tests/ui/incorrect_partial_ord_impl_on_ord_type_fully_qual.rs | UTF-8 | 1,083 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // This test's filename is... a bit verbose. But it ensures we suggest the correct code when `Ord`
// is not in scope.
#![no_main]
#![no_implicit_prelude]
//@no-rustfix
extern crate std;
use std::cmp::{self, Eq, Ordering, PartialEq, PartialOrd};
use std::option::Option::{self, Some};
use std::todo;
// lint
#[derive(... | true |
928b3d6772317b8ad4af53024c337163900bcfbd | Rust | snuk182/anl-rs | /src/implicit_modifier.rs | UTF-8 | 2,700 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::implicit_base::ImplicitModuleBase;
use super::ImplicitModule;
use super::curve::Curve;
use super::utility::clamp;
use std::rc::Rc;
use std::cell::RefCell;
pub struct ImplicitModifier {
base: ImplicitModuleBase,
source: Option<Rc<RefCell<ImplicitModule>>>,
curve: Curve<f64>,
}
impl ImplicitModi... | true |
aa3390b1038ebecc22a59b8f6044187df6f5ff2b | Rust | dduan/mmm | /src/mmm/commands/git_command.rs | UTF-8 | 2,577 | 3.109375 | 3 | [] | no_license | use std::process;
use std::io::Write;
use super::Command;
use super::utils;
use termcolor::{
Buffer,
BufferWriter,
Color,
ColorChoice,
};
pub struct GitCommand {
in_git: bool
}
fn run_git(arg1: String, arg2: String) -> bool {
let mut git = process::Command::new("git");
git.arg(arg1);
g... | true |
e61398240a9ef88ed22e461bc2267be758c20494 | Rust | rust-lang/rust | /tests/ui/suggestions/assoc-ct-for-assoc-method.rs | UTF-8 | 618 | 3.296875 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | struct MyS;
impl MyS {
const FOO: i32 = 1;
fn foo() -> MyS {
MyS
}
}
fn main() {
let x: i32 = MyS::foo;
//~^ ERROR mismatched types
//~| HELP try referring to the
let z: i32 = i32::max;
//~^ ERROR mismatched types
//~| HELP try referring to the
// This example is stil... | true |
09ffc35f115afaffcc555e65691eefa7ae643f20 | Rust | mcqueen256/gol-wasm | /src/universe.rs | UTF-8 | 13,211 | 2.75 | 3 | [] | no_license | use crate::utils;
use crate::config;
use crate::rle_loader;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys;
use getrandom;
#[wasm_bindgen]
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Cell {
Dead = 0,
Alive = 1
}
#[wasm_bindgen]
pub struct Universe {
width: u32,
... | true |
bcdb04e86072b86af5c63915f9f11a3c48230524 | Rust | llogiq/shoggoth.rs | /src/hlist.rs | UTF-8 | 2,063 | 3.171875 | 3 | [
"MIT"
] | permissive | /// Heterogeneous lists
#[rustc_on_unimplemented = "`{Self}` is not a heterogeneous list"]
pub trait HList {}
/// Empty heterogeneous list
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Nil;
impl HList for Nil {}
/// Cons heterogeneous list
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, P... | true |
934a5f168a3b85d444f308cd5e30cd9696b75048 | Rust | Garvys/rustfst-images-doc | /src/closure.rs | UTF-8 | 915 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use std::path::Path;
use failure::Fallible;
use rustfst::algorithms::{closure, ClosureType};
use rustfst::DrawingConfig;
use crate::fsts::fst_002;
use crate::utils::generate_image;
pub fn generate_closure_images<P: AsRef<Path>>(path_images: P) -> Fallible<()> {
let path_images = path_images.as_ref();
let fs... | true |
8663f6f15db778ed05403f2bfa645ccb7ffa5ce1 | Rust | JetASAP/firestore-db-and-auth-rs | /src/credentials.rs | UTF-8 | 10,723 | 2.71875 | 3 | [
"MIT"
] | permissive | //! # Credentials for accessing the Firebase REST API
//! This module contains the [`crate::credentials::Credentials`] type, used by [`crate::sessions`] to create and maintain
//! authentication tokens for accessing the Firebase REST API.
use chrono::Duration;
use serde::{Deserialize, Serialize};
use serde_json;
use s... | true |
456c81cd8f6aa2e1b26cc0e36bbb954d29974473 | Rust | mxinden/paxos-simulator | /src/nack/proposer.rs | UTF-8 | 10,457 | 2.65625 | 3 | [] | no_license | use super::Body;
use crate::{Address, Epoch, Header, Instant, Msg, Node, Value};
use std::collections::VecDeque;
const TIMEOUT: Instant = Instant(10);
/// A sequential proposer, handling a single request at a time.
#[derive(Debug)]
pub struct Proposer {
address: Address,
pub acceptors: Vec<Address>,
inbox... | true |
70d2ed9989426720e9e3b6489273038342b36739 | Rust | rayon-rs/rayon | /rayon-core/src/scope/test.rs | UTF-8 | 19,034 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::unwind;
use crate::ThreadPoolBuilder;
use crate::{scope, scope_fifo, Scope, ScopeFifo};
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
use std::cmp;
use std::iter::once;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Barrier, Mutex};
use std::vec;
#[test]
fn scope_empty() {
... | true |
0a3ec555c7e93f68515a353f35cb8183488ad684 | Rust | sunjay/async-std | /src/stream/stream/take.rs | UTF-8 | 933 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};
/// A stream that yields the first `n` items of another stream.
#[derive(Clone, Debug)]
pub struct Take<S> {
pub(crate) stream: S,
pub(crate) remaining: usize,
}
impl<S: Unpin> Unpin for Take<S> {}
impl<S: Stream> Take<S> {
... | true |
57a5b7fdeeb8f9dd22278aef2981397937e1c5d0 | Rust | kwsm114514/typical90 | /MyAnswers/ans027.rs | UTF-8 | 346 | 2.59375 | 3 | [] | no_license | use proconio::{input, fastout};
#[fastout]
fn main() {
input!{n: usize, users: [String; n]}
// hashsetで計算量を改善
let mut hs = std::collections::HashSet::new();
for i in 0..n {
if hs.contains(&users[i]) {
continue;
}
println!("{}", i + 1);
hs.insert(&users[i... | true |
56d4428eebbb5e80a65e4e90645021e4337fdf3e | Rust | wezm/dslite2svd | /crates/tm4c123x/src/sysctl/rcgc0/mod.rs | UTF-8 | 9,882 | 2.625 | 3 | [
"0BSD",
"BSD-3-Clause"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::RCGC0 {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R { bits: self.register.get() }
}
}
#[doc = r" Value of the field"]
pub struct WDT0R {
bits: bool,
}
impl WDT0R {
... | true |
102886f3b68c0e784232dd641457acb0533b6a46 | Rust | ggez/ggez | /examples/graphics_settings.rs | UTF-8 | 7,723 | 2.828125 | 3 | [
"MIT"
] | permissive | //! An example of how to play with various graphics modes settings,
//! resize windows, etc.
//!
//! Prints instructions to the console.
use std::convert::TryFrom;
use ggez::conf;
use ggez::event;
use ggez::graphics::Rect;
use ggez::graphics::{self, Color, DrawMode, DrawParam};
use ggez::input::keyboard::KeyCode;
use ... | true |
3265012c5ac233e835171e119656af7067d124c8 | Rust | mmn-siddiqui/IOT-Rust-Language | /Assignment 3.rs | UTF-8 | 568 | 3.546875 | 4 | [] | no_license | #[derive(Debug)]
struct Student {
name : String,
age : u8,
grade : String,
percentage : f32
}
impl Student {
fn construct(name:String,age:u8,grade:String,percentage:f32)-> Student {
Student {
name,
age,
grade ,
percentage
... | true |
05575028d40ea95b9664f1dee7e50e64c35a9fc0 | Rust | ftilde/rust-x86asm | /src/test/instruction_tests/instr_cmpxchg8b.rs | UTF-8 | 2,005 | 2.578125 | 3 | [
"MIT"
] | permissive | use instruction_def::*;
use test::run_test;
use Operand::*;
use Reg::*;
use RegScale::*;
use RegType::*;
use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
#[test]
fn cmpxchg8b_1() {
run_test(
&Instruction {
mnemonic: Mnemonic::CMPXCHG8B,
... | true |
d176d55d9d06ca1f2e784f2932185bc8183a55a0 | Rust | Atul9/sqelf | /sqelf/src/server.rs | UTF-8 | 19,980 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use std::{
marker::Unpin,
net::SocketAddr,
str::FromStr,
time::Duration,
};
use futures::{
future::{
BoxFuture,
Either,
},
select,
};
use tokio::{
net::signal::ctrl_c,
prelude::*,
runtime::Runtime,
sync::oneshot,
};
use bytes::{
Bytes,
BytesMut,
};
... | true |
31feb43160ae36f939139f7cb81fb8ed4a137957 | Rust | Buzzec/kapto_web | /src/game/ruleset/starting_positions/placement_area.rs | UTF-8 | 3,029 | 3.171875 | 3 | [] | no_license | use std::collections::HashSet;
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::fmt;
use serde::{Deserialize, Serialize};
use crate::game::coordinate::{Coordinate, flip_coordinate, rotate_coordinate};
use crate::game::ruleset::board_type::space::Space;
use crate::game::ruleset::Ruleset;
///... | true |
72ad157b1e373f83c03c71dcd40a8d45b01ee2f1 | Rust | art-in/meteos | /notifications/src/notification.rs | UTF-8 | 2,180 | 2.640625 | 3 | [] | no_license | use crate::{
backend_api,
config::ReadingRanges,
reading::ReadingOptimality,
sample::Sample,
tg_bot::{GetTgMessage, TgMessage, TgMessageFormat},
utils::beautiful_string_join,
};
use std::{fmt::Debug, time::Duration};
#[derive(Debug)]
pub struct NotOptimalReadingsNotification {
pub not_optim... | true |
3842550a0730f7d908eeda82ea06cb4d13a21cf1 | Rust | skial/back-to-basics | /rustlang/types/scalar/integer/assign/src/main.rs | UTF-8 | 82 | 2.6875 | 3 | [
"MIT"
] | permissive | fn main() {
let int:i32 = 33;
println!("The value of int is: {}", int);
}
| true |
623e4007fa92fd25d6066efbab2019a47afae878 | Rust | boylede/rusty-celery | /src/beat/mod.rs | UTF-8 | 9,393 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | /// This module contains the implementation of the Celery **beat**, which is a component
/// that can be used to automatically execute tasks at scheduled times.
///
/// ### Terminology
///
/// This is the terminology used in this module (with references to the corresponding names
/// in the Python implementation):
/// ... | true |
5c53a52b8b4c839e833b67e1fbf66df4b69c36dd | Rust | mufeedvh/jam0001 | /HectorHW/src/execution/objects.rs | UTF-8 | 1,834 | 3.171875 | 3 | [] | no_license | use std::fmt::{Display, Formatter};
use crate::parsing::ast::{Stmt};
use crate::parsing::token::Token;
use crate::execution::predef::RcNative;
#[derive(Clone)]
pub enum Object {
String(String),
Num(i64),
Function(Vec<Stmt>, Vec<Token>),
NativeFunction(RcNative, usize)
}
impl Object {
pub fn is_tru... | true |
602534f9947aba688ab0e8751d364ca4b6322efc | Rust | fiz3d/fiz | /math/src/unit/m.rs | UTF-8 | 2,384 | 3.71875 | 4 | [
"BSD-3-Clause"
] | permissive | use num::traits::{Num, NumCast};
use super::cm::{CM, ToCM};
use super::mm::{MM, ToMM};
use super::km::{KM, ToKM};
/// ToM is the canonical trait to use for taking input in meters.
///
/// For example the millimeters type (MM) implements the ToM trait and thus
/// millimeters can be given as a parameter to any input t... | true |
abf8e84f6e322851825a7949a1e8b2e684f1900a | Rust | thomasrockhu/Toshi | /src/handlers/search.rs | UTF-8 | 7,722 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::sync::{Arc, RwLock};
use futures::{future, Future};
use log::info;
use tower_web::*;
use crate::index::IndexCatalog;
use crate::query::Request;
use crate::results::ScoredDoc;
use crate::results::SearchResults;
use crate::Error;
#[derive(Clone)]
pub struct SearchHandler {
catalog: Arc<RwLock<IndexCatalog... | true |
233094a367021de0c19e949db94b99c4fa684bab | Rust | aDotInTheVoid/ltxmk | /src/strings.rs | UTF-8 | 570 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Important strings
/// Regexes for errors
const FILE_NOT_FOUND: &[&str] = &[
r"^No file\s*(.*)\.$",
r"^\! LaTeX Error: File `([^\']*)\' not found\.",
r"^\! I can\'t find file `([^\']*)\'\.",
r".*?:\d*: LaTeX Error: File `([^\']*)\' not found\.",
r"^LaTeX Warning: File `([^\']*)\' not found",
... | true |
afe6b4dd48ed31c4b8cddc9b009e8175369c2181 | Rust | royvegard/aoc_2020 | /src/day11.rs | UTF-8 | 5,975 | 3.375 | 3 | [
"MIT"
] | permissive | #[aoc(day11, part1)]
pub fn solve_part1(input: &str) -> usize {
game_of_seats(input)
}
#[aoc(day11, part2)]
pub fn solve_part2(input: &str) -> usize {
game_of_seats_los(input)
}
#[derive(Clone)]
struct Seat {
state: char,
next_state: char,
}
fn game_of_seats(input: &str) -> usize {
let mut layout... | true |
6000291393620c887c11dae9a3c010d817217f93 | Rust | arynh/cs419-ray-tracer | /src/hittable/sphere.rs | UTF-8 | 2,685 | 3.46875 | 3 | [
"MIT"
] | permissive | use crate::hit_record::HitRecord;
use crate::hittable::aabb::AABB;
use crate::hittable::Hittable;
use crate::material::MaterialType;
use crate::ray::Ray;
use glm::Vec3;
/// Represent a sphere in space
pub struct Sphere {
/// center point of the sphere
pub center: Vec3,
/// radius of the sphere
pub radi... | true |
dba39f431b7319e1ce22790309ba8a7f41d10feb | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/nomura2020/src/bin/c.rs | UTF-8 | 611 | 2.75 | 3 | [] | no_license | use std::cmp;
use proconio::input;
fn main() {
input! {
n: usize,
a: [usize; n + 1],
};
if a[0] > 1 {
println!("-1");
return;
}
let mut v = 1_usize - a[0];
let mut b = vec![(v, a[0])];
for &a_i in a.iter().skip(1) {
if a_i > v * 2 {
prin... | true |
2f27fe9a511ebe1c6942b688a4752a8c090cdad8 | Rust | coreos/fedora-coreos-cincinnati | /commons/src/web.rs | UTF-8 | 2,989 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use crate::graph::GraphScope;
use actix_cors::CorsFactory;
use failure::{bail, ensure, err_msg};
use std::collections::HashSet;
/// Build a CORS middleware.
///
/// By default, this allows all CORS requests from all origins.
/// If an allowlist is provided, only those origins are allowed instead.
pub fn build_cors_mid... | true |
32cf67a2e10acaab036d922b0e020704a169f992 | Rust | zwhitchcox/leetcode_rs | /src/_0118_pascal_triangle.rs | UTF-8 | 815 | 3.46875 | 3 | [
"MIT"
] | permissive | struct Solution;
impl Solution {
fn generate(nums_rows: i32) -> Vec<Vec<i32>> {
let mut res: Vec<Vec<i32>> = vec![];
for i in 0..nums_rows {
let ui = i as usize;
res.push(vec![]);
for j in 0..=i {
let uj = j as usize;
if j == 0 || ... | true |
b48f255e812ecbff84a496c69c4c654161c553de | Rust | markatk/serial-unit-testing | /src/parser/mod.rs | UTF-8 | 12,564 | 2.578125 | 3 | [
"MIT"
] | permissive | /*
* File: src/parser/mod.rs
* Date: 02.10.2018
* Author: MarkAtk
*
* MIT License
*
* Copyright (c) 2018 MarkAtk
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restricti... | true |
b0a2b15bb2efee1f3b8cca863d3b0009b1774762 | Rust | fiberseq/fibertools-rs | /bamlift/src/lib.rs | UTF-8 | 11,509 | 3.03125 | 3 | [] | no_license | use itertools::multiunzip;
use rust_htslib::{bam, bam::ext::BamRecordExtensions};
use std::collections::HashMap;
use std::fmt::{Debug, Display};
/// Merge two lists into a sorted list
/// Normal sort is supposed to be very fast on two sorted lists
/// <https://doc.rust-lang.org/std/vec/struct.Vec.html#current-implemen... | true |
910e5ae364c0195372c300fd265b447af6322f0a | Rust | Surpris/rs-deep | /src/dlfs01/common/functions.rs | UTF-8 | 1,949 | 3.078125 | 3 | [
"MIT"
] | permissive | //! functions
//!
//! functions used for neural network
use super::util::cast_t2u;
use num_traits::Float;
/// identity function
pub fn identity<T>(x: &[T]) -> Vec<T>
where
T: Float,
{
x.to_vec()
}
/// ReLU function
pub fn relu<T>(x: &[T]) -> Vec<T>
where
T: Float,
{
let zero: T = cast_t2u(0.0);
x... | true |
07f783418f45ac26d46a01fb821deeff0cc4003e | Rust | pavlov-dmitry/photometer | /src/cookies.rs | UTF-8 | 381 | 2.6875 | 3 | [] | no_license | use iron::{ Request, headers };
pub trait Cookieable {
fn cookie( &self, &str ) -> Option<&String>;
}
impl<'a, 'b> Cookieable for Request<'a, 'b> {
fn cookie(&self, key: &str) -> Option<&String> {
self.headers.get::<headers::Cookie>()
.and_then( |cookies| cookies.iter().find( |&c| c.name =... | true |
d30a057b4f515e3d2c3734ce617a9c176d45ecb1 | Rust | danieldk/alpino-tokenizer | /alpino-tokenizer/src/alpino.rs | UTF-8 | 1,456 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | use std::io::BufRead;
use crate::postproc::postprocess;
use crate::preproc::preprocess;
use crate::tokenizer::Tokenizer;
use crate::util::str_to_tokens;
use crate::{FiniteStateTokenizer, TokenizerError};
/// Alpino tokenizer and sentence splitter.
pub struct AlpinoTokenizer {
inner: FiniteStateTokenizer,
}
impl... | true |
0ee779a1d6fdedc03ee70b383cdc196cb6b6d31d | Rust | couchand/ccrb-export | /src/model.rs | UTF-8 | 2,836 | 2.96875 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
#[derive(Debug, Serialize)]
pub struct Officer {
pub id: String,
pub command: String,
pub last_name: String,
pub first_name: String,
pub rank: String,
pub shield_no: String,
}
impl core::convert::TryFrom<Vec<String>> for Officer {
type Error = DeserializeError;
f... | true |
fb26d3e0a0c88beb25e0720c28b3a04fd3f3660e | Rust | Keksoj/suivre_le_rust_book | /15_Smart_Pointers/drop/src/main.rs | UTF-8 | 626 | 3.390625 | 3 | [] | no_license | // 2019-07-07
// Le trait Drop permet de customise ce qui se passe quand une valeur sort du
// scope. La plupart du temps, on implémente Drop en cas de Smart Pointer.
struct CustomSmartPointer {
data: String,
}
impl Drop for CustomSmartPointer {
fn drop(&mut self) {
println!("Dropping CustomSmartPoint... | true |
201a9a251fd4bc3ae7d0a2e8b5bc898fe5b50002 | Rust | zawupf/aoc | /2019/rust/src/day01.rs | UTF-8 | 1,393 | 3.15625 | 3 | [
"MIT"
] | permissive | use crate::utils::read_input_lines;
pub fn job1() -> String {
read_input_lines("01")
.into_iter()
.map(|line| fuel_per_mass(line.parse::<i32>().expect("Parse i32 failed")))
.sum::<i32>()
.to_string()
}
pub fn job2() -> String {
read_input_lines("01")
.into_iter()
... | true |
6dc4c8d2029052baebae4264e03974019180eb55 | Rust | smithsps/challenges | /projecteuler/problem60/src/main.rs | UTF-8 | 3,810 | 3.3125 | 3 | [] | no_license | // Project Euler
// Problem 60 -
struct Sieve {
array: Vec<bool>,
}
impl Sieve {
fn with_capacity(size: usize) -> Sieve {
let mut new_sieve = Sieve {
array: vec![true; size],
};
new_sieve.array[0] = false;
new_sieve.array[1] = false;
let mut i = 3;
... | true |
1d5a1739c8e7a7f08a193f3ee5f5356a6f2909a8 | Rust | craigmayhew/bigprimes.net | /src/pages/archive/mersenne.rs | UTF-8 | 13,382 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::Msg;
use seed::prelude::*;
extern crate num_bigint;
extern crate num_traits;
pub mod mersenne_utils {
extern crate num_bigint;
extern crate num_traits;
use num_bigint::{BigInt, ToBigInt};
use num_bigint::{BigUint, ToBigUint};
use num_traits::{Num, Pow, ToPrimitive};
#[derive(Clone... | true |
3a3be78bf5cc65e404a284bafd2659a4310413ab | Rust | mermoldy/rc.machine | /src/common/src/types.rs | UTF-8 | 3,076 | 3.171875 | 3 | [
"MIT"
] | permissive | extern crate image;
extern crate serde;
use self::serde::{Deserialize, Serialize};
use std::fmt;
pub struct VideoFrame {
pub image: image::RgbImage,
pub timestamp_ms: i64,
}
#[derive(Serialize, Deserialize, Copy, Clone)]
pub struct MachineState {
pub forward: bool,
pub backward: bool,
pub left: b... | true |
79b0c45d05303a7ceaaf3457987f6655ddac2636 | Rust | jim4067/phoronix-reader | /src/phoronix_cli.rs | UTF-8 | 1,949 | 3.078125 | 3 | [] | no_license | use crate::article::Article;
use crate::homepage;
use crate::linesplit;
use term;
#[allow(dead_code)]
pub fn print() {
let phoronix_articles = Article::get_articles(&homepage::online()); //online//
// let phoronix_articles = Article::get_artic... | true |
7f30f8f6ae17f2ed25dd9b84da5db78d88bc1218 | Rust | Pick1a1username/Mastering-Python-Design-Patterns-Second-Edition-In-Rust | /chapter02/exercise_fluent_builder/src/main.rs | UTF-8 | 1,300 | 3.921875 | 4 | [
"MIT"
] | permissive | struct Pizza {
garlic: bool,
extra_cheese: bool,
}
impl Pizza {
fn new(builder: PizzaBuilder) -> Pizza {
Pizza {
garlic: builder.garlic,
extra_cheese: builder.extra_cheese,
}
}
fn get_info(&self) -> String {
let garlic = {
if self.garlic ... | true |
51baf222a138958483230c4abfcbb7831cc5d792 | Rust | rune-rs/rune | /crates/rune/src/runtime/vm_call.rs | UTF-8 | 2,912 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::no_std::sync::Arc;
use crate::runtime::vm_execution::VmExecutionState;
use crate::runtime::{
Call, Future, Generator, RuntimeContext, Stack, Stream, Unit, Value, Vm, VmErrorKind,
VmExecution, VmResult,
};
/// An instruction to push a virtual machine to the execution.
#[derive(Debug)]
#[must_use = "... | true |
5a4b148582a484038629604722f76c9ba9c2142d | Rust | oatzy/fungus | /src/agent.rs | UTF-8 | 2,916 | 3.515625 | 4 | [] | no_license | use std::collections::VecDeque;
use std::convert::TryInto;
use anyhow::{bail, Error, Result};
#[derive(Clone, Copy)]
pub enum Direction {
N,
NE,
E,
SE,
S,
SW,
W,
NW,
}
impl TryInto<Direction> for usize {
type Error = Error;
fn try_into(self) -> Result<Direction> {
Ok(m... | true |
e050a285a7d8da6cc6988555d5dec2d5a7cc3d5b | Rust | rust-native-ui/libui-rs | /iui/src/ui.rs | UTF-8 | 8,802 | 3.125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use callback_helpers::{from_void_ptr, to_heap_ptr};
use error::UIError;
use ffi_tools;
use std::os::raw::{c_int, c_void};
use ui_sys;
use std::ffi::CStr;
use std::marker::PhantomData;
use std::mem;
use std::rc::Rc;
use std::thread;
use std::time::{Duration, SystemTime};
use controls::Window;
/// RAII guard for the U... | true |
b74b6dfffa9c274ea9d957b6b9ba254169eef94c | Rust | Animeshz/git-mit | /git-mit/src/cli/app.rs | UTF-8 | 3,107 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"CC0-1.0"
] | permissive | use clap::{crate_authors, crate_version, App, Arg};
use indoc::indoc;
pub fn app() -> App<'static> {
App::new(String::from(env!("CARGO_PKG_NAME")))
.bin_name(String::from(env!("CARGO_PKG_NAME")))
.version(crate_version!())
.author(crate_authors!())
.about(env!("CARGO_PKG_DESCRIPTION... | true |
1341e2ecae25a5fbdc71c099107a9a93b74df92c | Rust | jamwaffles/sh1106 | /src/interface/spi.rs | UTF-8 | 1,613 | 2.890625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! sh1106 SPI interface
use hal::{self, digital::v2::OutputPin};
use super::DisplayInterface;
use crate::Error;
/// SPI display interface.
///
/// This combines the SPI peripheral and a data/command pin
pub struct SpiInterface<SPI, DC, CS> {
spi: SPI,
dc: DC,
cs: CS,
}
impl<SPI, DC, CS, CommE, PinE> Sp... | true |
37485b44a2219831b18ff5352447bd3effbe1d32 | Rust | FlxB2/fapra-algorithms-optimizations | /osm-tasks/src/persistence/in_memory_routing_repo.rs | UTF-8 | 1,628 | 2.734375 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use crate::persistence::routing_repo::RoutingRepo;
use crate::model::grid_graph::Node;
pub(crate) struct InMemoryRoutingRepo {
routes: Vec<ShipRoute>,
}
impl RoutingRepo for InMemoryRoutingRepo {
fn new() -> InMemoryRoutingRepo {
InMemoryRoutingRepo {
r... | true |
6a1ae50bc76f5914466d22ae43aa825d49748747 | Rust | N5FPP/stm32f7xx | /stm32f7x9/src/dsi/dsi_fir0/mod.rs | UTF-8 | 16,174 | 2.6875 | 3 | [] | no_license | #[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::DSI_FIR0 {
#[doc = r" Writes to the register"]
#[inline]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
let mut w = W::reset_value();
f(&mut w);
self.register.se... | true |
085dbbaacd9b5a2bf6d23d21f444bfbc266c3acd | Rust | bikeshedder/deadpool | /src/managed/hooks.rs | UTF-8 | 4,847 | 2.984375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Hooks allowing to run code when creating and/or recycling objects.
use std::{fmt, future::Future, pin::Pin};
use super::{Manager, Metrics, ObjectInner};
/// The result returned by hooks
pub type HookResult<E> = Result<(), HookError<E>>;
/// The boxed future that should be returned by async hooks
pub type HookFu... | true |
402ed30df4f81e238db2e3bdc93c80dce5a191e5 | Rust | ThomasHauth/ros2_rust | /rclrs/src/publisher/loaned_message.rs | UTF-8 | 2,939 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use std::ops::{Deref, DerefMut};
use rosidl_runtime_rs::RmwMessage;
use crate::rcl_bindings::*;
use crate::{Publisher, RclrsError, ToResult};
/// A message that is owned by the middleware, loaned for publishing.
///
/// It dereferences to a `&mut T`.
///
/// This type is returned by [`Publisher::borrow_loaned_messag... | true |
56bd2164bc8c2c7ddac12844c366132cf46d6393 | Rust | HeartANDu/rust-snake | /src/lib.rs | UTF-8 | 9,350 | 3.1875 | 3 | [] | no_license | extern crate termion;
extern crate rand;
use rand::Rng;
use std::fmt;
const SCORE_PER_MICE: u32 = 100;
pub trait CanMove {
fn do_move(&mut self);
fn set_velocity(&mut self, velocity: Velocity);
}
#[derive(Copy, Clone)]
pub struct Velocity {
vel_x: i16,
vel_y: i16,
}
impl Velocity {
pub fn new(v... | true |
34a00bc05fed7f2b7be2097372e80355e0648300 | Rust | colin-daniels/typing | /src/paren/ops/any_all.rs | UTF-8 | 836 | 2.640625 | 3 | [] | no_license | use crate::boolean::{AndFn, False, OrFn, True};
use crate::paren::ops::{Fold, FoldOut, Map, MapOut};
pub trait All<F> {
type Output;
fn all(self) -> Self::Output;
}
impl<F, T> All<F> for T
where
Self: Map<F>,
MapOut<F, Self>: Fold<AndFn, True>,
{
type Output = FoldOut<AndFn, MapOut<F, Self>, True>... | true |
37e2e9c2968c8b6376fd81fefec78c2f602a3b7b | Rust | mich2000/smartapp | /backend/jwt-gang/src/claim_config.rs | UTF-8 | 4,102 | 3.28125 | 3 | [] | no_license | use crate::claim::Claim;
use crate::claim_error::JwtCustomError;
use jsonwebtoken::errors::ErrorKind;
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
/**
* This configuration will be used to make claims and to validate these claims. The maximum expiration that can be given... | true |
a034d6184443454bbf2036b6df5ec17965d5ba73 | Rust | thekuom/serde_json_tracing_bunyan_formatter_bug_report | /src/lib.rs | UTF-8 | 363 | 3 | 3 | [] | no_license | use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Bar {
pub baz: i32,
}
#[derive(Debug, Deserialize)]
pub struct Foo {
#[serde(flatten)]
pub bar: Bar,
}
#[test]
fn deserialize() {
let result: Foo = serde_json::from_str(
r#"{
"baz": 1
}"#,
)
.expect("... | true |
f94dae51c7b2a645c4ccf33be060e123d629443f | Rust | bch29/battlebots | /support/src/math.rs | UTF-8 | 4,493 | 3.8125 | 4 | [
"MIT"
] | permissive | /// Serialisable 2D vectors.
pub mod vector {
use cgmath;
use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, MulAssign};
/// A two dimensional vector with `f64` components.
#[derive(PartialEq, PartialOrd, Debug, Clone, Copy, Default, Serialize, Deserialize)]
pub struct Vector2 {
pub x: f64... | true |
95e1ac9239bc546edf24a4ff2fed2a7880a2ce67 | Rust | rsfyi/rust-basics | /src/enums/enumvalues.rs | UTF-8 | 569 | 3.109375 | 3 | [] | no_license | /*
* - Enums as a types for the field of struct
* - Predefined values
* - using different types inside enums
*/
#[derive(Debug)]
enum IpAddrKind {
V4,
V6,
}
#[derive(Debug)]
struct IpAddr {
kind: IpAddrKind,
address: String,
}
pub fn run() {
let ip_addr_v4 = IpAddr {
kind: IpAddrKind:... | true |
e82972a49be19ef7fae31aaf9cafeb93877e7b17 | Rust | notmandatory/gun | /src/amount_ext.rs | UTF-8 | 944 | 3.265625 | 3 | [
"0BSD"
] | permissive | use std::str::FromStr;
use anyhow::anyhow;
use bdk::bitcoin::{Amount, Denomination};
pub trait FromCliStr: Sized {
fn from_cli_str(string: &str) -> anyhow::Result<Self>;
}
impl FromCliStr for Amount {
fn from_cli_str(string: &str) -> anyhow::Result<Self> {
match string.rfind(char::is_numeric) {
... | true |
a2293c5b4a72b5441b18a88dc4afd20c17f49ed6 | Rust | HerrFrutti/tanoshi | /src/proxy.rs | UTF-8 | 3,323 | 3.046875 | 3 | [
"MIT"
] | permissive | use bytes::Bytes;
use serde::Deserialize;
use std::convert::Infallible;
use warp::{filters::BoxedFilter, hyper::Response, Filter, Reply};
#[derive(Deserialize)]
pub struct Image {
pub url: String,
}
pub fn proxy() -> BoxedFilter<(impl Reply,)> {
warp::path!("image")
.and(warp::get())
.and(warp... | true |
abc056b6a6e4071a285d6fba97997c199a3b410d | Rust | aspires/lucet | /lucet-runtime/lucet-runtime-internals/src/instance.rs | UTF-8 | 29,913 | 2.71875 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | mod siginfo_ext;
pub mod signals;
pub use crate::instance::signals::{signal_handler_none, SignalBehavior, SignalHandler};
use crate::alloc::Alloc;
use crate::context::Context;
use crate::embed_ctx::CtxMap;
use crate::error::Error;
use crate::instance::siginfo_ext::SiginfoExt;
use crate::module::{self, Global, Module}... | true |
bd59fec92eefee725c06e41f46fc1809f41d76b5 | Rust | drahnr/yubihsm-rs | /src/serial_number.rs | UTF-8 | 2,310 | 3.15625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer};
use std::{
fmt::{self, Debug, Display},
str::{self, FromStr},
};
use connector::{ConnectionError, ConnectionErrorKind::AddrInvalid};
/// Length of a YubiHSM2 serial number
pub const SERIAL_SIZE: usize = 10;
/// YubiHSM seria... | true |
905991a96c0984bc28dfef8700457355ceca6fc5 | Rust | dantengsky/curve25519-dalek | /src/utils.rs | UTF-8 | 1,103 | 2.65625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause"
] | permissive | // -*- mode: rust; -*-
//
// This file is part of curve25519-dalek.
// Copyright (c) 2016-2017 Isis Lovecruft, Henry de Valence
// See LICENSE for licensing information.
//
// Authors:
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
// - Henry de Valence <hdevalence@hdevalence.ca>
//! Miscellaneous common utili... | true |
0f76900244ea99dbfa217cc04ad33c8977371a67 | Rust | atoav/bender-worker | /src/work/ratelimit.rs | UTF-8 | 2,968 | 3.328125 | 3 | [
"MIT"
] | permissive | use ::*;
use chrono::prelude::DateTime;
use chrono::Utc;
/// The RateLimiter allows to exponentially backoff failing tasks
#[derive(Debug, Default, Clone, Copy)]
pub struct RateLimiter{
last: Option<DateTime<Utc>>,
last_failed: Option<DateTime<Utc>>,
n_failed: usize,
n_max: usize,
... | true |
34fd9d1ef1383bad261ee6cec0df7fc69365c13a | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/dwango2015-prelims/src/bin/b.rs | UTF-8 | 666 | 2.875 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
s: Chars,
};
if s.len() == 1 {
println!("{}", 0);
return;
}
let mut v = vec![];
let mut i = 0;
while i < s.len() {
if s[i] == '2' && i + 1 < s.len() && s[i + 1] == '5' {
v.pus... | true |
5497d6e97bbf8e6aa4af1bba6d871a47266363bc | Rust | n8henrie/exercism-exercises | /rust/bob/src/lib.rs | UTF-8 | 790 | 3.171875 | 3 | [
"MIT"
] | permissive | const QUESTION_RESPONSE: &str = "Sure.";
const YELLING_RESPONSE: &str = "Whoa, chill out!";
const YELLING_QUESTION_RESPONSE: &str = "Calm down, I know what I'm doing!";
const SILENCE_RESPONSE: &str = "Fine. Be that way!";
const DEFAULT_RESPONSE: &str = "Whatever.";
pub fn is_yelling(m: &str) -> bool {
m.contains(c... | true |
b95d86a16eb8be25fbd01ae6558b4b3c8b7e02cb | Rust | S-YOU/rapidus | /src/vm/error.rs | UTF-8 | 269 | 2.5625 | 3 | [
"MIT"
] | permissive | use ansi_term::Colour;
#[derive(Debug, Clone, PartialEq)]
pub enum RuntimeError {
Unknown,
Type(String),
Reference(String),
Unimplemented,
}
pub fn runtime_error(msg: &str) {
eprintln!("{}: {}", Colour::Red.bold().paint("runtime error"), msg,);
}
| true |
df51cc9bcb57cab9a8d2a7f15934c2b1c2a9e202 | Rust | pnkfelix/euca | /examples/todomvc/src/lib.rs | UTF-8 | 23,235 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use cfg_if::cfg_if;
use log::{debug,info,error};
use euca::app::*;
use euca::route::Route;
use euca::dom;
use serde::{Serialize,Deserialize};
use serde_json;
cfg_if! {
if #[cfg(feature = "console_error_panic_hook")] {
#[inline]
fn set_panic_ho... | true |
4180a72850f942dfa9c7ad0c00e630c86c135031 | Rust | cih-y2k/RustyTarantool | /src/tarantool/packets.rs | UTF-8 | 6,456 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | #![allow(non_camel_case_types)]
use std::io;
use std::str;
use rmpv::{Value};
use serde::{Serialize, Deserialize};
use tarantool::tools;
use bytes::{Bytes ,IntoBuf};
/// tarantool auth packet
#[derive(Debug)]
pub struct AuthPacket {
pub login: String,
pub password: String,
}
/// tarantool packet intended f... | true |
781fdeb1243bd028f811be05361cfa2bd885ece5 | Rust | jvff/dkr | /src/dockerfile/run_commands.rs | UTF-8 | 912 | 2.96875 | 3 | [] | no_license | use super::single_or_multiple_items_visitor::SingleOrMultipleItemsVisitor;
use serde::{Deserialize, Deserializer};
use std::fmt::{self, Display, Formatter};
#[derive(Debug)]
pub struct RunCommands {
commands: Vec<String>,
}
impl<'de> Deserialize<'de> for RunCommands {
fn deserialize<D>(deserializer: D) -> Res... | true |
4e016d9bd0ffb1582bb23ec896e783cec641830f | Rust | tgolsson/kludgine | /core/src/shape/stroke.rs | UTF-8 | 1,042 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use easygpu_lyon::lyon_tessellation::StrokeOptions;
use figures::Figure;
use crate::{color::Color, math::Scaled};
/// A shape stroke (outline) options.
#[derive(Default, Clone, Debug)]
pub struct Stroke {
/// The color to stroke the shape's with.
pub color: Color,
/// The options for drawing the stroke.
... | true |
8fe1fac422f31134708af4caac62cbc396ce8cb1 | Rust | bonifaido/rust-sophia | /examples/example.rs | UTF-8 | 3,071 | 2.75 | 3 | [] | no_license | extern crate sophia;
use sophia::Native;
fn main() {
println!("## Setup ##");
let env = sophia::Sophia::new().unwrap();
println!("env type {}", env.get_type().unwrap());
let ctl = env.ctl();
let res = ctl.set("sophia.path", "./target/test.db");
println!("ctl.set {:?}", res.unwrap());
le... | true |
1761e09522a13368946271fb4e7a0b49dbbd8a2a | Rust | Volland/steel | /steel/src/steel_vm/engine.rs | UTF-8 | 20,880 | 2.75 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::{
options::{ApplyContract, DoNotApplyContracts, DoNotUseCallback, UseCallback},
primitives::{embed_primitives, embed_primitives_without_io, CONSTANTS},
vm::VirtualMachineCore,
};
use crate::{
compiler::{compiler::Compiler, constants::ConstantMap, program::Program},
core::instructions::Den... | true |
3d788e08b89a857d4e64b234e91d8255f6986b3f | Rust | gnoliyil/fuchsia | /src/fonts/manifest/src/v1_to_v2.rs | UTF-8 | 13,234 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Utilities for conversion from Font Manifest v1 to v2.
use {
crate::{v2, Family as FamilyV1, Font as FontV1, FontsManifest as FontsManifestV1},
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.